PDA

View Full Version : Collision Detection


Lucifera
02-26-2009, 11:17 AM
i need my ninja not to walk through walls. Any ideas?

JustasM
02-26-2009, 11:53 AM
There are several worlds that are shared that employ collision detection. For example, check out the JetStix world in the Madden games thread.

http://www.alice.org/community/showthread.php?t=1159&page=2

Usually, you do collision detection by using proximity functions: If the object you are moving is within e.g. 1 meter of 'wall', set the object's speed to 0/ decrease speed/ move backward.

Try and experiment a bit, or simply look at someone else's code and imitate it.. You're allowed to do that! ;)

Good luck!

*EDIT*
Or, simply, under the events tab, 'let arrow keys move object', if that is applicable to your world. It will prevent the object from moving through walls.

However, beware: the object is able to move through walls and objects if it is moving backwards, so it can be exploited in certain worlds/games. Collision detection works, for certain reasons, only during forward movement.