OnAdd for Trigger object
by Ricardo Arango · in Technical Issues · 10/15/2008 (3:55 pm) · 1 replies
Hi,
I defined a trigger, with a datablock, like this:
And I need some variables, specific to each instance of a trigger, so they shouldn't be defined in the datablock, as everything in a datablock is static, right?
So I thought that using the onAdd function, called when the simObject is added to the scene, would do the trick. So I tried two approaches
But none worked. So, how could I do this?
Thank you.
I defined a trigger, with a datablock, like this:
datablock TriggerData(TriggerCalle){
tickPeriodMS = 500;
className = "classTriggerCalle";
};And I need some variables, specific to each instance of a trigger, so they shouldn't be defined in the datablock, as everything in a datablock is static, right?
So I thought that using the onAdd function, called when the simObject is added to the scene, would do the trick. So I tried two approaches
// 1.
function classTriggerCalle::onAdd(%triggerDB, %trigger)
{
%trigger.rules = 7;
}
// 2.
function TriggerCalle::onAdd(%triggerDB, %trigger)
{
%trigger.rules = 7;
}But none worked. So, how could I do this?
Thank you.
Ricardo Arango
For some reason, it doesn't call the TriggerData's onAdd function. But, it is possible to call it from the Trigger class.
function Trigger::onAdd(%triggerDB, %trigger){ %db = %trigger.dataBlock; %db.onAdd(%triggerDB, %trigger); }So now I can have an onAdd on any TriggerData, like this:
datablock TriggerData(TriggerDataName){ tickPeriodMS = 500; }; function TriggerDataName::onAdd(%triggerDB, %trigger) { ... }Don't now if it's optimal, but it works.