Game Development Community

Collision polygon problem....

by Raja John · in Torque Game Builder · 01/17/2009 (7:04 am) · 3 replies

How to set collision polygon to EXACT image shape?

like this a.imagehost.org/0844/collision1.png
Thanks in advance.

#1
01/18/2009 (10:40 am)
Why not make a bunch of nodes that follow the shape exactly?

I do not recommend it, "pixel perfect" collision is hyped up but unnecessary most times. The TGB collision system is not designed to be that precise, as you show in the image above.
#2
01/27/2009 (10:32 pm)
You could use multiple overlapping circles for collision. Just make invisible t2dsceneobjects with a collision circle and mount them to your fish, and have them callback collision. If you turn on visible collision bounds in the debug options you could line up the collision objects quite accurately. It won't be pixel perfect, but it should be good enough.
#3
01/29/2009 (2:56 pm)
Hahah, yeah I've done that overlapping technique before that conor suggests.
The problem is TGB doesn't support concave collision shapes.. lameo! I get past this by creating a few fish images mounted togeather, each with a different part of the fish's collision polygon.

maybe:
1 for the whole body.
1 for the tail
5 for the fins (1 per fin)

It's overkill, but that's your easiest bet. Now if you have lots of fish you can create all the parts of this, then programatically spawn them with the layers all mounted togeather. You can even drop one of the fish objects into the editor and give it a class name like: fishClass.

then on your onSceneLoaded callback class you can put your complex fish collision sandwhich code in there... works pretty easily actually.. that's what I would do. Let me know if you're unclear on how to do this and i'll give you some sample code.