Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: FritsLyn on July 12, 2013, 02:15:39 PM
-
Hi, I cannot at this stage see any delay, but I'd hate to make "dirty code".
My question is:
Is the example shown on the attached picture going to run several tests for trigger events, or just 1, and then do 4 comparisons?
I am probably going to have some 20 in total when done (this is the main character). Should I make one trigger event and then get info, put to string, make switch etc - or is it "clean" as shown?
Thanks :)
-
Hi,
You are fine. what is bad practice ( imo...) is to really on TriggerStay, while it's fine in normal scripts, it's not really good in fsm, because events are fired every frame. instead prefer using trigger enter and exit and maintain a boolean flag.
but in your case it's all good, I do this all the time.
bye,
Jean
-
Thanks a bunch! :)
-
I create a custom action with pairs of tag and event to check for different tag value. Something like this:
[CompoundArray("tag Switches", "Compare Tag", "Send Event")]
[UIHint(UIHint.Tag)]
public FsmString[] collideTags;
public FsmEvent[] sendEvents;
Then inside DoTriggerEnter
if (trigger == TriggerType.OnTriggerEnter)
{
for (int i = 0; i < collideTags.Length; i++)
{
if (other.gameObject.tag == collideTags.Value)
{
Fsm.Event(sendEvents[i]);
StoreCollisionInfo(other);
return;
}
}
}
Hope that help :)
-
Uh - I cannot code enough to make use - that's why i am using PlayMaker :)
I can read the code though, but am in doubt, would this be a cleaner (faster) method?
Thanks!
-
Uh - I cannot code enough to make use - that's why i am using PlayMaker :)
I can read the code though, but am in doubt, would this be a cleaner (faster) method?
Thanks!
its definitely cleaner than having one trigger event for each tag value. Performance-wise, it should be more or less the same .
-
Thank you :)
(Clean in CPU cycles is all that matters to me ;) )