Game Development Community

Generated Collision Poly

by Ian Omroth Hardingham · in Torque Game Builder · 01/24/2007 (12:58 pm) · 2 replies

Hi everyone.

Just playing around with TGB, completely new to it.

I've got a class inheriting from T2DStaticSprite which randomly generates a convex polygon as it's shape. I've got the generating and rendering done, but now I'm trying to set the size of the thing and set the custom collision poly.

I create it with:

new MyClass(Blah) {
      imageMap = "playerShipImageMap";
      frame = "0";
      canSaveDynamicFields = "1";
      class = "Asteroid";
      position = "400 20";
      size = "1 1";
      mountID = "2";
      scenegraph = $pShip.scenegraph;
      CollisionActiveSend = "1";
      CollisionActiveReceive = "1";
      CollisionGroups = "-33";
      CollisionResponseMode = "BOUNCE";
   };[code]


Then in c I do the following:

[code]setSize(newSize);
setCollisionPolyCustom(nPoints, points);

What format does the custom poly need to be in? I have it as a list of points whose coordinates are %s of size, so each between 0 and 1, but am having no luck so far.

Any help would be greatly appreciated.

Ian

#1
01/24/2007 (2:05 pm)
Ian's post was a bit confusing, because he's directly mixing TorqueScript and C++ code without a noticeable break.

In which class method are you doing the size change Ian, and why directly in c++?
#2
01/26/2007 (10:31 am)
Thanks Stephen... I managed to work it out in the end.

Ian