Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: MaDDoX on May 02, 2011, 07:28:43 PM
-
Supposing you want to broadcast an event after a specific trigger event, by default you always have to drive the execution flow to another state (using Trigger Event), and in that state you execute the 'broadcast event' action. In some circumstances this can be really bad since some messages just have to be sent/broadcasted as quickly as possible and there's apparently some minor overhead (delay) in switching states, which can make all the difference between things working as you want or not. I've created 'Trigger Broadcast Event' exactly to fill this gap - although I recognize that a proper SubFSM structure (a mini-FSM which would be executed in the same update and return to the calling point once finished) would be perfect for such scenarios and instantly render such actions obsolete.
Yet the clock won't stop ticking, so, meanwhile.. enjoy :)
-
Hi,
Yes, subFsm, or mini fsm standing on its own would be really handy sometimes, not only in that case but also for reusable behaviors etc etc.
Bye,
Jean
-
Hi,
Yes, subFsm, or mini fsm standing on its own would be really handy sometimes, not only in that case but also for reusable behaviors etc etc.
Bye,
Jean
Fully agree, an subFsm that could be used as always looking for a sent variable from another Fsm. I've needed that on lots of occasions and I don't really like the workarounds I have. They work, but way too much unnecessary work that could be avoided.
Thanks again for the custom action MaddoX, you rock.
-
Thanks to you for the kind words Tobbeo :)
We're actually on a roll with new actions here at the studio, I barely have the time to post them hehe. Curiously we agree that most of them will be deprecated once the new system for global variables and nested/subFSMs kick in, yet it's a great exercise on action creation and it's allowing us to be fully productive right away. That's the kind of flexibility that any user loves in a tool, and why I say - Alex, you rock! ^_^
-
No you guys rock! Love to see the community sharing actions and helping each other out this much - I'm just trying to keep up my end of the deal ;)
-
This is exactly what I need, but where is the code?
-
Ok, I modified the Trigger Event with some code from the new Send Event action. It's dirty but it does the trick. Require you to set the collider to a variable and then to reuse that variable as the target.
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// Modified by Studio Interrupt
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Detect collisions with a Tagged trigger.\nNOTE: TRIGGER ENTER, TRIGGER STAY, and TRIGGER EXIT are sent automatically when objects collide with ANY trigger. Use this action to send custom events when colliding with a particular Tag.")]
public class TriggerEventToCollider : FsmStateAction
{
public TriggerType trigger;
[UIHint(UIHint.Tag)]
public FsmString collideTag;
public FsmEvent sendEvent;
[UIHint(UIHint.Variable)]
public FsmGameObject storeCollider;
//public FsmBool sendToCollider;
public FsmEventTarget eventTarget;
public override void Reset()
{
trigger = TriggerType.OnTriggerEnter;
collideTag = "Untagged";
sendEvent = null;
storeCollider = null;
//sendToCollider = false;
}
void StoreCollisionInfo(Collider collisionInfo)
{
storeCollider.Value = collisionInfo.gameObject;
}
public override void DoTriggerEnter(Collider other)
{
if (trigger == TriggerType.OnTriggerEnter)
{
if (other.gameObject.tag == collideTag.Value)
{
StoreCollisionInfo(other);
//Fsm.Event(sendEvent);
Fsm.Event(eventTarget, sendEvent);
}
}
}
public override void DoTriggerStay(Collider other)
{
if (trigger == TriggerType.OnTriggerStay)
{
if (other.gameObject.tag == collideTag.Value)
{
StoreCollisionInfo(other);
//Fsm.Event(sendEvent);
Fsm.Event(eventTarget, sendEvent);
}
}
}
public override void DoTriggerExit(Collider other)
{
if (trigger == TriggerType.OnTriggerExit)
{
if (other.gameObject.tag == collideTag.Value)
{
StoreCollisionInfo(other);
//Fsm.Event(sendEvent);
Fsm.Event(eventTarget, sendEvent);
}
}
}
public override string ErrorCheck()
{
return ActionHelpers.CheckOwnerPhysicsSetup(Owner);
}
}
}
-
This is exactly what I need, but where is the code?
It's attached to the first post. Can't you see it? :o
-
Now I do, thanks for pointing that out!