Thanks Lane,
Something like that would be great, the key to my project is that every button has a different effect upon the object and when two or three buttons are pressed another effect is spawned. so each int value created through the Int operator with then spawn an individual action from the Int switch,
I am so close with the tools that are there, I just need to get Int compare to work with more than two variable.
I had a go at the code but I am certainly no expert!
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Performs math operation on 2 Integers: Add, Subtract, Multiply, Divide, Min, Max.")]
public class IntOperator : FsmStateAction
{
public enum Operation
{
Add,
Subtract,
Multiply,
Divide,
Min,
Max
}
[RequiredField]
public FsmInt integer1;
[RequiredField]
public FsmInt integer2;
[RequiredField]
public FsmInt integer3;
[RequiredField]
public FsmInt integer4;
public Operation operation = Operation.Add;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt storeResult;
public bool everyFrame;
public override void Reset()
{
integer1 = null;
integer2 = null;
integer3 = null;
integer4 = null;
operation = Operation.Add;
storeResult = null;
everyFrame = false;
}
public override void OnEnter()
{
DoIntOperator();
if (!everyFrame)
Finish();
}
// NOTE: very frame rate dependent!
public override void OnUpdate()
{
DoIntOperator();
}
void DoIntOperator()
{
int v1 = integer1.Value;
int v2 = integer2.Value;
int v3 = integer2.Value;
int v4 = integer2.Value;
switch (operation)
{
case Operation.Add:
storeResult.Value = v1 + v2 + v3 + v4;
break;
case Operation.Subtract:
storeResult.Value = v1 - v2 - v3 - v4;
break;
case Operation.Multiply:
storeResult.Value = v1 * v2 * v3 * v4;
break;
case Operation.Divide:
storeResult.Value = v1 / v2 / v3 / v4;
break;
case Operation.Min:
storeResult.Value = Mathf.Min(v1, v2, v3, v4);
break;
case Operation.Max:
storeResult.Value = Mathf.Max(v1, v2, v3, v4);
break;
}
}
}
}
it seems to run fine but when I debug it just fires back a 0 for any value going through the third or fourth variable.
Thanks again,
L