Hey guys, i find myself in need of a script to compare an array index to about 10 other ints(options) and if i get a match set an object value to the object value specified on each of the 10 ints and then fire off a finish event.
I've gotten this far by just modifying a Int Switch, but no further
Could anybody give me some hints on how to actually set the object value in this script.
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Logic)]
[Tooltip("Sends an Event based on the value of an Integer Variable.")]
public class IntSwitchToObject : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt intVariable;
public FsmObject objectVariable;
[CompoundArray("Int Switches", "Compare Int", "Set Object")]
public FsmInt[] compareTo;
public FsmObject[] objectValue;
public bool everyFrame;
public override void Reset()
{
intVariable = null;
objectValue = null;
compareTo = new FsmInt[1];
objectVariable = null;
everyFrame = false;
}
public override void OnEnter()
{
DoIntSwitch();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoIntSwitch();
}
void DoIntSwitch()
{
if (intVariable.IsNone)
return;
for (int i = 0; i < compareTo.Length; i++)
{
if (intVariable.Value == compareTo[i].Value)
{
//objectVariable.Value = objectValue.Value;
return;
}
}
}
}
}
I could offcourse just use a Int Switch with 10 transitions, but that would be a lot of extra states.