Game Development Community

How to call a trigger onenter event from script

by Peterjohn Griffiths · in Torque Game Builder · 04/06/2011 (7:30 am) · 5 replies

I have a trigger onenter event that is triggered atleast once normaly by another object.
At some points in the scripts, I want to call the same triggers onenter event again with all the same variable refferences while the item that triggered the event is still within the trigger bounds of the trigger.
Is there a way of calling an event?, is it like calling a function?.
Will this run the onenter event in the same way as when triggered normaly by the object, so if there was code in the engine, this would also be run aswell as the script side.
Many thanks.

#1
04/06/2011 (9:49 am)
You want to use the onTickTrigger callback for that- define how often that trigger "ticks" and that defines how often the callback is called, which in turn calls the script function onTickTrigger, and then you can do whatever you need to do in there in the same way you do it in onEnterTrigger.
#2
04/06/2011 (5:57 pm)
Thats sound great.
I can't find an example in the documents to this.
I'm new to TGB.
Where would I find how to do this in TGB script.
Many thanks.
#3
04/06/2011 (6:37 pm)
I think I have figured it out.

function Triggername::onStay(%this, %theirObject)

Only problem, its only called every second or so.
Sort of works ok though. :D
Many thanks for your help, got me to a solution that will work.

:D
#4
04/07/2011 (6:08 am)
Just wondering if there is any way to speed up this triggername::onStay event so that instead of it running every second, it runs 3 or 4 times a second?.
#5
04/07/2011 (6:09 pm)
Managed to do this with the schedule command, but still get the same delay despite calling the schedule 3 or 4 times a second.
I can see the scheduled event being called and its running as expected, but the delay I see with the onstay event is the same.
I think this is due to something else in the code of the engine so there isn't a way around the problem.
Many thanks again Ted for your help on this.