# Collision Detection

5 posts

 12 posts How do most people do collision detection in Flash, in general because the hitTestObject is terrible with the hit box, especially for images that arn’t squares. 1. I am making a top down shooter In my game i have a character that rotates to face the mouse. He rotates around a center point. You move with the WASD keys and I want it so when he hits an object i dont want him to go through it. I have never done much with collision detection before and don’t understand much of it. Really could use a good step by step tutorial on the kind of collision detection im trying to do. Its not just simple box to box collision i need something that looks better than that. I also DONT want to use some outside package like people use in bitmap testing, I want to write my own code for this for practice Would greatly appreciate any help on this or ideas of where to go to learn more about collision detection 4090 posts You could `hitTestPoint`, but given that you don’t want it to overlap, you’ll have to do the calculations yourself. ie, “will it collide?” instead of “is it colliding?”. How do most people do it? That depends on each particular case; you can go from super basic math, to hardcore trigonometry to color comparison to… 566 posts Finding out if two circles have collided is easy. If you’re new to collision detection, make all your objects roughly circular and done! first game works. Box – box collision is easy too. From circles to ellipses is fairly straightforward. So your next game can have more interesting shaped objects and tighter collision detection. Then you can look up line-circle collision (needs some fairly complex math, but you can just plug in the formulas you find on the web) Small adjustment to get line-ellipse collision, then box/circle collision, and so on… And so on. Start with the basics. Split the problem into smaller ones. Build on what you’ve learned before. Your first game might be more basic than you want it to be, but you have to start somewhere. 364 posts 12 posts Thx curious gaming that’s what I will try to do. I’ve been experimenting with Rectangle objects and using those for collision detection now, it seems to be working pretty well at the moment. As most of my objects are roughly squares anyway.