list objects contained within a zone or trigger?
by Rex Hiebert · in Torque 3D Professional · 11/23/2009 (6:50 pm) · 7 replies
My game is played in an RTS mode (no player object). You are moving puzzle blocks around. I will need to list the objects that are within a zone or a trigger and be able to test an object to see which zone or trigger it is in. Is there an easy way to do this? The objects are being moved by setTransform and are not colliding with the triggers so i need to be able to test. (Using the trigger as more of an info-zone than an actual trigger). I would also need to know when the camera enters a certain zone or trigger or a least determine which one it is in at the time. Again, the camera does not have a control object so it does not collide with the triggers.
Any ideas?
Any ideas?
#2
It looks like I may have to write something into the engine that will process all objects and see if they are withing the bounds of the trigger. The only issue with that is that it is using polyhedron object for it's bounds and i'm having a hard time figuring out how to test objects. It looks like it wants to build convex shapes, etc to test.
11/23/2009 (7:21 pm)
That only seems to work if something has moved into the trigger by impulse or player movement, i.e. walking into it. My objects are selected the moved to the placement spot via setTransform. When I call getNumObjects() it returns 0 even when the block is sitting inside the trigger.It looks like I may have to write something into the engine that will process all objects and see if they are withing the bounds of the trigger. The only issue with that is that it is using polyhedron object for it's bounds and i'm having a hard time figuring out how to test objects. It looks like it wants to build convex shapes, etc to test.
#3
11/23/2009 (8:17 pm)
Incidentally, what are your objects? Class type - AIplayers, staticshapes, etc --- 'cos I don't thnik anything is going to detect a TsStatic (just incase you're using that) it's not what they are for.
#4
11/24/2009 (9:03 am)
Triggers only track ShapeBase-derived objects. TSStatic doesn't derive from ShapeBase, so use StaticShape instead (they also need datablocks).
#5
But at this time they are StaticShapes which are selected by clicking on them when in an RTS camera mode. The player then clicks on another surface and the block (StaticShape) is set to that position. It is not animating or following a path to get there, it just moves using setTransform. It seems that triggers are not activated by this kind of move.
11/24/2009 (10:34 am)
My objects are StaticShapes. That may be changing soon as I need to add physics to the objects. I'm looking at PhysX but may wait and see how things go with the recent addition of Bullet.But at this time they are StaticShapes which are selected by clicking on them when in an RTS camera mode. The player then clicks on another surface and the block (StaticShape) is set to that position. It is not animating or following a path to get there, it just moves using setTransform. It seems that triggers are not activated by this kind of move.
#6
11/24/2009 (11:02 am)
Then I think StaticShapes don't register with triggers and some small code changes are needed. Either that or maybe there's a class you can use... I *think* the Item class can interact with triggers.
#7
I did try creating the objects as items and had some success with that but will need to move towards a more complete physics sim (PhysX or Bullet) so I put that aside for the moment.
11/24/2009 (1:31 pm)
I think i may just go the route of coding some sort of InfoZone that can be queried to find out what's inside. In my case it doesn't need to trigger events like a trigger. I just need to know where things are.I did try creating the objects as items and had some success with that but will need to move towards a more complete physics sim (PhysX or Bullet) so I put that aside for the moment.
Associate Steve Acaster
[YorkshireRifles.com]
eg:
for(%x=0; %x < %trigger.getNumObjects(); %x++) { %obj = %trigger.getObject(%x); //then go check if a certain object is in the list }