Page 1 of 1

CollisionFree() moves actor???

PostPosted: Mon Sep 27, 2010 6:52 am
by akr
It seems that "CollisionFree()" changes position of an actor. The moveto() function which is executed afterwards
moves even if I specify "0" as value.

Has anyone expierience with the "collisionfree()" function?

Thx
andreas

int n;
Actor *actors;

char *key = GetKeyState(); //Get entire keyboard state

if(xvelocity == 0 && yvelocity ==0)
{
if(key[KEY_RIGHT] == 1) //Test if right key is pressed
{
CollisionFree("Event Actor", x+32, y);

actors = getAllActorsInCollision("Event Actor", &n);


if(n==0 ||(n==1 && !strncmp(actors[0].name,"ground",6)))
MoveTo("Event Actor", 0.000000, 0.000000, 4.000000, "hero", "");
}

if(key[KEY_LEFT] == 1) //Test if left key is pressed
{
CollisionFree("Event Actor", x-32, y);

actors = getAllActorsInCollision("Event Actor", &n);


if(n==0 ||(n==1 && !strncmp(actors[0].name,"ground",6)))
MoveTo("Event Actor", 0.000000, 0.000000, 4.000000, "hero", "");
}

if(key[KEY_UP] == 1)
{
CollisionFree("Event Actor", x, y-32);

actors = getAllActorsInCollision("Event Actor", &n);


if(n==0 ||(n==1 && !strncmp(actors[0].name,"ground",6)))
MoveTo("Event Actor",0.0,-0.000000, 4.000000, "hero", "");
}

if(key[KEY_DOWN] == 1)
{
CollisionFree("Event Actor", x, y+32);

actors = getAllActorsInCollision("Event Actor", &n);


if(n==0 ||(n==1 && !strncmp(actors[0].name,"ground",6)))
MoveTo("Event Actor", 0.0,0.000000, 4.000000, "hero", "");
}
}

Re: CollisionFree() moves actor???

PostPosted: Mon Sep 27, 2010 7:09 am
by savvy
try using xscreen and yscreen, unless you mean it changes visual position aswell.

Re: CollisionFree() moves actor???

PostPosted: Mon Sep 27, 2010 7:20 pm
by jimmynewguy
I personally have only used collision free as a conditional statement.
Code: Select all
if(CollisionFree("Event Actor", x+32, y))
{
//do some stuff
}

Doubt that really helps anything...

EDIT: for get all actors in collision, it seems to avoid problems to reset your actor variable every time you use it so it doesn't get confused and think there are still actors - so second line should be
Code: Select all
Actor *actors=NULL;

Re: CollisionFree() moves actor???

PostPosted: Mon Sep 27, 2010 8:52 pm
by akr
I am pretty sure its a bug. Collisionfree() shouldnt impact anything.