CollisionFree() moves actor???

You must understand the Game Editor concepts, before post here.

CollisionFree() moves actor???

Postby akr » Mon Sep 27, 2010 6:52 am

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", "");
}
}
Co-Developer of GE engine

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score

Re: CollisionFree() moves actor???

Postby savvy » Mon Sep 27, 2010 7:09 am

try using xscreen and yscreen, unless you mean it changes visual position aswell.
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: CollisionFree() moves actor???

Postby jimmynewguy » Mon Sep 27, 2010 7:20 pm

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;
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: CollisionFree() moves actor???

Postby akr » Mon Sep 27, 2010 8:52 pm

I am pretty sure its a bug. Collisionfree() shouldnt impact anything.
Co-Developer of GE engine

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest