Triggers and Flying Vehicles (once again)
by Martin Schultz · in Torque Game Engine · 10/21/2004 (11:42 am) · 7 replies
Hi,
I'm trying to get it to work that flying vehicles actually produce an trigger event when flying through triggers. I read through most of the trigger posts here in the forums and I wasn't able to really find the solution from the posts.
I tried in the FlyingVehicle.cc file to extend the mask:
I compared also the wheeledVehicle files against the flyingVehicle files, but wasn't able to see the magic difference as I read somewhere in the forums that triggers should work with the wheeled vehicles. Can anyone light my darkness and solve this issue?
Thanks for any help! :-)
Best,
Martin
I'm trying to get it to work that flying vehicles actually produce an trigger event when flying through triggers. I read through most of the trigger posts here in the forums and I wasn't able to really find the solution from the posts.
I tried in the FlyingVehicle.cc file to extend the mask:
sServerCollisionMaskto include also the TriggerObjectType like this:
static U32 sServerCollisionMask = (sCollisionMoveMask | TriggerObjectType);but the only thing happens is that the ship collides with the trigger instead of creating a trigger event.
I compared also the wheeledVehicle files against the flyingVehicle files, but wasn't able to see the magic difference as I read somewhere in the forums that triggers should work with the wheeled vehicles. Can anyone light my darkness and solve this issue?
Thanks for any help! :-)
Best,
Martin
#2
I looked at the source this morning but couldn't find that what you mean. The only thing that catched me was the "objectMask" variable, but I wasn't able to find where it comes from or where it is filled. Did you mean that one?
Anyone? :-)
Best,
Martin
10/21/2004 (9:38 pm)
Hi,I looked at the source this morning but couldn't find that what you mean. The only thing that catched me was the "objectMask" variable, but I wasn't able to find where it comes from or where it is filled. Did you mean that one?
Anyone? :-)
Best,
Martin
#3
10/22/2004 (12:45 pm)
Bump di bump... anyone? :-)
#4
Team 1 trigger entered by this = 182 Trig = 1922 obj = 2055
'this' is the trigger's datablock ID#
'Trig' is the trigger's objectID#
'obj' is the vehicle's objectID#
So as far as I can tell, it should work. What version of TGE are you using?
10/22/2004 (3:10 pm)
Martin, just out of curiosity I ran a test to see if my flying vehicle would trigger a basic trigger and it did, I got this in my echo....Team 1 trigger entered by this = 182 Trig = 1922 obj = 2055
'this' is the trigger's datablock ID#
'Trig' is the trigger's objectID#
'obj' is the vehicle's objectID#
So as far as I can tell, it should work. What version of TGE are you using?
#5
hmm, well, I have to say this is strange - I think I found the bug. May be that the cause was that I missed to write this line
Best,
Martin
10/23/2004 (1:15 pm)
Hi,hmm, well, I have to say this is strange - I think I found the bug. May be that the cause was that I missed to write this line
MissionGroup.add(%trigger);after creating the trigger. It seems I simply forgot the add it to the missiongroup as it seems. Thanks Gonzo that you tried it - this kept me up searching for the reason :-)
Best,
Martin
#6
10/23/2004 (1:25 pm)
Glad to help, I only wish I had actually tried it myself before sending you on a wild goose chase in the TGE code. My apologies for that.
#7
Best, Martin
10/24/2004 (2:23 am)
Nevermind - in the end you directed me in the right direction! :-) Thanks!Best, Martin
Torque Owner Gonzo T. Clown
In vehicle.cc you would find....
// Trigger objects that are not normally collided with. static U32 sTriggerMask = ItemObjectType | TriggerObjectType | CorpseObjectType;And also....
void Vehicle::checkTriggers() { Box3F bbox = mConvex.getBoundingBox(getTransform(), getScale()); gServerContainer.findObjects(bbox,sTriggerMask,findCallback,this); }And your error is being created here(most likely)....
void Vehicle::findCallback(SceneObject* obj,void *key) { Vehicle* vehicle = reinterpret_cast<Vehicle*>(key); //U32 objectMask = obj->getTypeMask(); U32 objectMask = obj->getTypeMask(); // Check: triggers, corpses and items, basically the same things // that the player class checks for if (objectMask & TriggerObjectType) { Trigger* pTrigger = static_cast<Trigger*>(obj); pTrigger->potentialEnterObject(vehicle); } else if (objectMask & CorpseObjectType) { ShapeBase* col = static_cast<ShapeBase*>(obj); vehicle->queueCollision(col,vehicle->getVelocity() - col->getVelocity()); } else if (objectMask & ItemObjectType) { Item* item = static_cast<Item*>(obj); if (vehicle != item->getCollisionObject()) vehicle->queueCollision(item,vehicle->getVelocity() - item->getVelocity()); } }