Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: tobbeo on April 10, 2011, 08:21:23 PM
-
Very simple "FloatSubtract" action as requested by fis.
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// Simple custom action by Tobbe Olsson - www.tobbeo.net
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Adds a value to a Float Variable.")]
public class FloatSubtract : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat floatVariable;
[RequiredField]
public FsmFloat subtract;
public bool everyFrame;
public bool perSecond;
public override void Reset()
{
floatVariable = null;
subtract = null;
everyFrame = false;
perSecond = false;
}
public override void OnEnter()
{
DoFloatSubtract();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoFloatSubtract();
}
void DoFloatSubtract()
{
if (!perSecond)
floatVariable.Value -= subtract.Value;
else
floatVariable.Value -= subtract.Value * Time.deltaTime;
}
}
}
-
Way to go, Tobbeo! ;)
-
Thanks! :D
-
This is great! I'm excited to see people helping each other out with actions - leaves us with more time to work on core features! ;)
-
This is great! I'm excited to see people helping each other out with actions - leaves us with more time to work on core features! ;)
Maybe this goes without saying, and I just modified one of your actions but feel free to include it in the release. It's a very basic, but handy addition.
-
Will definitely include it - thanks!