Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Collision Detection (http://www.alice.org/community/showthread.php?t=2315)

Lucifera 02-26-2009 11:17 AM

Collision Detection
 
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.

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

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.


All times are GMT -5. The time now is 09:06 AM.

Copyright ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.