Hi,
I was trying to modify the send event FSM to make one that will broadcast an event to all gameObjects on a layer. I was just copy/pasting stuff from different scripts, but no surprise failed miserably. I need this for a sort of RTS game where i'd like the AI-controlled units on different teams to be able to issue orders to each other.
UPDATE: Ok, so i realized that in my case i could also sort by tags just as well, but i couldn't get that to work either. This is what i tried to paste together.
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using System;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.StateMachine)]
[Tooltip("Sends an Event after an optional delay. NOTE: To send events between FSMs they must be marked as Global in the Events Browser.")]
public class SendEventToTagged : FsmStateAction
{
[RequiredField]
[Tooltip("The event to send. NOTE: Events must be marked Global to send between FSMs.")]
public FsmEvent sendEvent;
[RequiredField]
[UIHint(UIHint.Tag)]
[Tooltip("Only consider objects with this Tag. NOTE: It's generally a lot quicker to find objects with a Tag!")]
public FsmString withTag;
public override void Reset()
{
withTag = "Untagged";
sendEvent = null;
}
public override void OnEnter()
{
GameObject[] objects;
objects = GameObject.FindGameObjectsWithTag(withTag.Value);
foreach (GameObject obj in objects)
{
Fsm.Event(obj, sendEvent);
}
}
}
}
I also need to have it ignore itself when broadcasting. Help?