Game Development Community

Collision for stationairy things

by Christian · in Torque Game Engine · 08/27/2007 (12:20 am) · 3 replies

Anyone ever done collision for a stationairy item? If you put a trigger over a player, it won't recognize them until they move, or if you .setTransform and item on a player, it won't detect their collision unless they move. Is there a way to detect players that aren't moving's collsion? I see in triggers.cs there is a function for getObject(n), but it doesn't work nor is it it the trigger's dump().

#1
08/27/2007 (10:08 am)
You can get the object entering a trigger in the trigger code:

function myTrigger::onEnterTrigger(%this,%trigger,%obj)


%obj is the object entering the trigger.
%obj.client will give the client

If you wanted to use the tick you use:

function myTrigger::onTickTrigger(%this,%trigger)
{
...

// loop thru all the objects in the trigger 
for(%x=0; %x < %trigger.getNumObjects(); %x++) 
{         
//  Set %obj to be the current object that is being used in the for loop.
%obj = %trigger.getObject(%x);

...
}

edit: You can then check if that object is a client and if it's alive then do whatever...

To check if it's a dead client...
if (%obj.getState() $= "Dead")
{
return;
}
#2
08/27/2007 (10:44 pm)
Thanks for the response, ::onenter doesn't help since I need the people who are already in it when it's created. The same goes for ::onTickTrigger, it doesn't detect anyone whose already there unless they move. Basically I need to create a trigger or something of the like and find out whose already in that spot without them moving.
#3
08/27/2007 (10:55 pm)
I have the same problem in our MMO. One of our spells creates a "fire trap" on the ground. In addition to the dts model, it spawns a trigger on top of the model. If a player is already standing on the trap, it won't fire. I think the solution would be to add a method in a triggers onAdd() that searches the scene for existing objects inside the trigger.