Page 1 of 1

Collision checking?

PostPosted: Tue Jul 05, 2011 11:57 am
by Guardian69
Hi guys

I have two actors that require collision. One is the player actor and the other is a scenery actor.

I want to be able to check if an actor can move into a space before they do. Ideally I would use a function to check the proposed 2d vector and return a Boolean value that identified if it was occupied.

Does such a thing exist? If not how would I set one up?

Cheers,
Guardian

Re: Collision checking?

PostPosted: Tue Jul 05, 2011 3:44 pm
by Imperialjester
they have a function called collisionfree that does just that.

Re: Collision checking?

PostPosted: Tue Jul 05, 2011 4:01 pm
by Guardian69
Ah awesome! Thank you!

"CollisionFree: Check if position (x, y) is collision free for ActorName. Return 1 if not collide, 0 otherwise."

So if I am using the following script in my players draw event, how would I get the player actors next x and y?

"yvelocity = yvelocity + 1;
xvelocity *= .95;"

Re: Collision checking?

PostPosted: Tue Jul 05, 2011 5:33 pm
by Imperialjester
i dont know im not an expert on it. ask Hblade hes a good coder.

Re: Collision checking?

PostPosted: Tue Jul 05, 2011 8:08 pm
by skydereign
The actor's next position will be (x+xvelocity, y+yvelocity) assuming you have already changed xvelocity and yvelocity (after this part).
Code: Select all
yvelocity = yvelocity + 1;
xvelocity *= .95

If not, you position will be (x+xvelocity*0.95, y+yvelocity+1).