Dynamic Triggers?
by Charles Williams · in Technical Issues · 09/25/2002 (12:51 pm) · 13 replies
Anyone puzzle out how to do this?
About the author
#2
09/26/2002 (2:42 pm)
I'd like to pre-define the area of a trigger around an object so whenever it is placed it will create the trigger effect for that object.
#3
09/27/2002 (4:29 am)
Sorry but my english is not very good and i did not get what you meant.
#4
09/27/2002 (9:05 am)
I mean rather than define *every* trigger in the game. I'd like to set it up so that certian triggers are linked to certian objects. How do I do this?
#5
09/27/2002 (9:16 am)
Well you could create the trigger in the object's onAdd() function.... i've done this before...
#6
09/27/2002 (9:41 am)
exodus, can you paste a code snippet?
#7
09/27/2002 (10:26 am)
yeah, I am not quite clear how that code would look
#8
09/27/2002 (2:33 pm)
Should the trigger move with the object too?
#9
09/27/2002 (2:35 pm)
Xavier, I imagine the trigger would have to follow the object.
#10
09/28/2002 (10:35 am)
I'd say yes as well :)
#11
09/28/2002 (1:21 pm)
Yes, but if that is not possible, have it automatically reset the trigger when the object stops moving.
#12
But it was simple, suppose you have an object called MyFlag. Then in that object's MyFlag::onAdd(%this, %obj) function you create a new trigger using something like:
Of course you would previously have to define the trigger datablock. Though... this only created the trigger when the object was added, ie when you created it using the editor or when the mission loaded the object. You could make a simple function that should be executed while moving the object, or when it finishes loading that would set the triggers transform to the objects transform... (you have a reference to the trigger object in %this.trigger, so it wouldn't be hard. I don't have time to look how to make a function that is executed when the object is finished moving or something but I'll try to give it a look later on.
Good Luck
09/28/2002 (6:03 pm)
Well, I don't have the code for that anymore since I said I "did" it once....But it was simple, suppose you have an object called MyFlag. Then in that object's MyFlag::onAdd(%this, %obj) function you create a new trigger using something like:
%this.trigger = new Trigger() {
datablock = DefinedDataBlock;
};Of course you would previously have to define the trigger datablock. Though... this only created the trigger when the object was added, ie when you created it using the editor or when the mission loaded the object. You could make a simple function that should be executed while moving the object, or when it finishes loading that would set the triggers transform to the objects transform... (you have a reference to the trigger object in %this.trigger, so it wouldn't be hard. I don't have time to look how to make a function that is executed when the object is finished moving or something but I'll try to give it a look later on.
Good Luck
#13
09/29/2002 (1:34 pm)
Thanks
Torque 3D Owner Frank Bignone
Darkhand Studio