AS3 Collision Resolution

Started by
1 comment, last by wildbunny 11 years, 7 months ago
Hey, im trying to figure out collision resolution in as3. I have detection and stuff working i just cant figure out how to resolve it!?! any ideas?
Advertisement
Collision detection in AS3 is done by call hitTestObject() function. That's all what you need. If you want check collisions for your object continuously - you can test collisions for each frame.
To resolve collisions you need to use some simple mathematics with vectors.
If you need to lock object movement when it's under wall (or floor, or ceiling), you need to check test collision and if it was found, prevent changing object coordinates.
If you need to reflect object movement (as billiard balls, for example), you just need compute movement vector according to simple physics rule. These rules depends on your environment. In simple situation it will be just a ray reflection. Of course, its very primitive methods, if you need more realistic image, you need to know physics laws and formulas. But often for AS3 it's enough.

Hey, im trying to figure out collision resolution in as3. I have detection and stuff working i just cant figure out how to resolve it!?! any ideas?


If you're looking for polygonal collision detection and resolution in AS3, I have a couple of articles which might interest you:

http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/
http://www.wildbunny.co.uk/blog/2011/12/14/how-to-make-a-2d-platform-game-part-2-collision-detection/

Cheers, Paul.

This topic is closed to new replies.

Advertisement