Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on August 30, 2012, 04:36:43 AM
-
Hi,
Following a post, please find an action to return the square root of a float.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Get a Float Variable square root value")]
public class FloatSquareRoot : FsmStateAction
{
public FsmFloat floatVariable;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat result;
public bool everyFrame;
public override void Reset()
{
floatVariable = null;
result = null;
everyFrame = false;
}
public override void OnEnter()
{
DoFloatSquareRoot();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoFloatSquareRoot();
}
void DoFloatSquareRoot()
{
if (!result.IsNone)
{
result.Value = Mathf.Sqrt(floatVariable.Value);
}
}
}
}
bye,
Jean
-
Just posting on this one Jean as a possible missed action for the latest version of playmaker? I could not find the Squareroot math function as a default in Playmaker.
-
Hi,
It's on the Ecosystem (http://j.mp/1Esn1mF).
(http://i.imgur.com/L4z5hFD.png)
Bye,
Jean