How do you do accurate collision detection on non-round/rectangle objects?
Young Zaphod
Member Posts: 7
Collision uses a circle or rectangle of the actor to deter collisions, but I'm trying to do detection on a basically isosceles triangle ship. With the rectangle setting, it looks like things are colliding before hitting the ship, and with circle it sometimes looks like things are passing through.
My thought is to make the ship out of multiple smaller actors constrained to each other, but that seems like a big pain. Does anyone have a more elegant solution to this?
Best Answers
-
jonmulcahy Posts: 10,408
hopefully in the future we will have custom collision shapes, but for now it's just a rectangle and circle. You have to use hidden actors to provide collision shapes for different shaped actors.
Answers
I thought that might be the case but wanted to make sure before I built my game on that.
Thanks!
Like I say it's very straightforward, especially if the triangle is either static in one position (as in games where the actor stays in the middle of the screen and the environment moves) or if the triangle is moving around the screen but not rotating - then it's a simple case of throwing three long actors into the scene rotating them to the desired angle and constraining them to the main actor to form the triangle . . . . if on the other-hand the triangle needs to move around the screen and rotate and spin and so on, then you need to use a little trigonometry, if you're not familiar with cos and sin then - I've made a device that does all the maths for you . . . .
Link: http://forums.gamesalad.com/discussion/62202/linkmachine
. . .
Thanks Socks - unfortunately I have my space ship both rotating and moving around the screen, but fortunately having an engineering degree I have a good understanding of all the physics and math stuff involved. Getting that into GS is another story since I just started this two days ago...
Did you check out the link I posted above, it does all the work for you.