I'm not a programmer, but I need a to add a transition time when using "Convert Bool to Float". Right now it abruptly changes my float from X to the assigned True Value. I would like it to change over time. Could someone help with the CS portion please? Then we can share it with others. Here is all I have:
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Convert)]
[Tooltip("Converts a Bool value to a Float value with Dampening.")]
public class ConvertBoolToFloatDamp : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Bool variable to test.")]
public FsmBool boolVariable;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Float variable to set based on the Bool variable value.")]
public FsmFloat floatVariable;
[Tooltip("Float value if Bool variable is false.")]
public FsmFloat falseValue;
[Tooltip("Float value if Bool variable is true.")]
public FsmFloat trueValue;
[Tooltip("Repeat every frame. Useful if the Bool variable is changing.")]
public bool everyFrame;
[Tooltip("Optional: The time allowed to parameter to reach the value. Requires everyFrame Checked on")]
public FsmFloat dampTime;
public override void Reset()
{
boolVariable = null;
floatVariable = null;
falseValue = 0;
trueValue = 1;
everyFrame = false;
}
public override void OnEnter()
{
DoConvertBoolToFloat();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoConvertBoolToFloat();
}
void DoConvertBoolToFloat()
{
floatVariable.Value = boolVariable.Value ? trueValue.Value : falseValue.Value;
}
}
}