Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: qholmes on October 19, 2011, 10:38:33 AM

Title: Float Window Test
Post by: qholmes on October 19, 2011, 10:38:33 AM
Here is a little Action i made for doing a window test on float values.. has been very handy for me. Dont think there was already one here.. but i have been wrong before.

Q

Code: [Select]
//



using UnityEngine;



namespace HutongGames.PlayMaker.Actions

{

[ActionCategory(ActionCategory.Logic)]

[Tooltip("Sends Events based on a float being inside a window of values.")]

public class FloatWindowCompare : FsmStateAction

{

[RequiredField]

[Tooltip("Float to Check")]

public FsmFloat floatTest;

[RequiredField]

[Tooltip("Lower limit for window")]

public FsmFloat floatLower;

[RequiredField]

[Tooltip("Upper limit for window")]

public FsmFloat floatUpper;

[Tooltip("Event sent if FloatTest is inside the window")]

public FsmEvent inWindow;

[Tooltip("Event sent if FloatTest is outside the window")]

public FsmEvent outOfWindow;

public bool everyFrame;



public override void Reset()

{

floatTest = 0f;

floatLower = 0f;

floatUpper = 0f;

inWindow = null;

outOfWindow = null;

everyFrame = false;

}



public override void OnEnter()

{

DoCompare();



if (!everyFrame)

Finish();

}



public override void OnUpdate()

{

DoCompare();

}



void DoCompare()

{



if (floatTest.Value > floatLower.Value && floatTest.Value < floatUpper.Value)

{

Fsm.Event(inWindow);

return;

}



if (floatTest.Value < floatLower.Value || floatTest.Value > floatUpper.Value)

{

Fsm.Event(outOfWindow);

return;

}



}



public override string ErrorCheck()

{

if (FsmEvent.IsNullOrEmpty(inWindow ) &&

FsmEvent.IsNullOrEmpty(outOfWindow))

return "Action sends no events!";

return "";

}

}

}
Title: Re: Float Window Test
Post by: Dev_Sebas on October 19, 2011, 10:52:34 AM
Good luck
Title: Re: Float Window Test
Post by: qholmes on October 19, 2011, 10:53:32 AM
with what?


Q
Title: Re: Float Window Test
Post by: Dev_Sebas on October 19, 2011, 10:57:02 AM
With your amazing scripts
Title: Re: Float Window Test
Post by: qholmes on October 19, 2011, 10:59:15 AM
Ahh thanks...  ;D

but mine are very simple..

Q
Title: Re: Float Window Test
Post by: Dev_Sebas on October 19, 2011, 11:04:37 AM
For me it´s horrible the scripts
And thanks by your script I will test it later