Page 1 of 1

What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 3:56 pm
by Hblade
Title says all :3

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 4:03 pm
by skydereign
CollisionFree: Check if position (x, y) is collision free for ActorName. Return 1 if not collide, 0 otherwise.
int CollisionFree(char *actorName, int x, int y)
Actor name:
- "Event Actor": Actor that is receiving the current event.
- "Parent Actor": Event Actor's parent, if exists.
- "Creator Actor": Event Actor's creator, if Event Actor has been created in some "Create Actor" action.
- "Collide Actor": Actor that collided with the event Actor.
- Any Actor in game.


Script Editor Syntax:
if (CollisionFree("Event Actor", x, y+5)) y=y+5; //On KeyDown Event script for KEY_DOWN, check if there is no collision before moving an actor down by 5 pixels.

That is pulled from the script reference. It explains exactly what it is, and even has an example of how to use it. If you have further questions about it, do ask.

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 4:11 pm
by Hblade
Ahh thanks! So basically if done right you can have precise control of when the actor is colliding... This is perfect for basic movement systems and moreso for advanced!

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 4:14 pm
by skydereign
I assume you've read a bit of Game A Gogo's perfect collision demo's topic. There are some rather annoying problems with using CollisionFree. So while it is good for simple movement systems, more advanced games will often run into this problem. There are some cheap fixes you can use, but none of them are that great. You can use a similar system with just using collision actors that doesn't run into the problems.

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 4:18 pm
by Hblade
Yeah thats where I got this from. and oh. Thanks :)

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 9:41 pm
by SuperSonic
Does collision free check to see if there are any actors at x, y or does it just check if there are any collision actors at x, y? :)

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 10:30 pm
by skydereign
It checks if the actor would collide if moved to xy.

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 10:34 pm
by SuperSonic
And by collide you mean physical response? Or a collision event? :)

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 10:41 pm
by skydereign
It'd be easy to find out. But... it means colliding, as in the sprites intersect and would cause a collision event if there was a collision between the actors (but the collision event isn't necessary, just the CollisionState can't be disabled).

Re: What is collision free, and how do I use it?

PostPosted: Tue May 29, 2012 11:04 pm
by SuperSonic
Sweet! Thank you :D