PDA

View Full Version : How do I make collision detection work properly?


pkoss1
11-02-2009, 09:07 PM
Hey everybody... :D I've got a noob problem.

I am trying to create a game for my class involving collision detection. I searched the forums but couldn't find the answers I'm looking for.

What I have is a snowmobile which you must drive through a ravine, using the arrow keys to get away from a wolf (which eventually stops chasing you), while avoiding about ten pine trees that are in the way.

When the snowmobile's "move" variable is true, it repeatedly moves forward one meter and checks to see if any obstacles are too close. I tried to put this in a "do together" group but that just causes an error, so I have it happen in sequence instead. If you hit something or let the wolf get you, you are supposed to stop and see the words YOU FAIL appear.

It worked several times, but now for some reason you can just drive through the trees and ravine walls with impunity, and if the wolf catches you the whole thing crashes.

Also, it seems to me there's got to be a better way to handle collision detection, since right now the snowmobile just moves one meter, checks to see if it hit something, then moves another meter. This results in slow, jerky movement.

Can anyone help me? I attached the .a2w file in case you want to get a better idea of what I'm talking about. Thanks in advance.

x2495iiii
11-02-2009, 10:16 PM
Well, there isn't a built-in collision detection system, so typically you need to use if/else ifs inside infinity loops which check to see if the moving object is within a certain distance (usually the moving object's width) of other objects.