mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-13 15:52:03 +07:00
47 lines
1022 B
C#
47 lines
1022 B
C#
#if PLAYMAKER
|
|
using UnityEngine;
|
|
using HutongGames.PlayMaker;
|
|
using IsoTools.PlayMaker.Internal;
|
|
|
|
namespace IsoTools.PlayMaker.Actions {
|
|
[ActionCategory("IsoTools.Physics")]
|
|
[HutongGames.PlayMaker.Tooltip(
|
|
"Gets the Speed of a IsoRigidbody and stores it in a Float Variable.")]
|
|
public class IsoGetSpeed : IsoComponentAction<IsoRigidbody> {
|
|
[RequiredField]
|
|
[CheckForComponent(typeof(IsoRigidbody))]
|
|
public FsmOwnerDefault gameObject;
|
|
|
|
[RequiredField]
|
|
[UIHint(UIHint.Variable)]
|
|
public FsmFloat storeResult;
|
|
|
|
public bool everyFrame;
|
|
|
|
public override void Reset() {
|
|
gameObject = null;
|
|
storeResult = null;
|
|
everyFrame = false;
|
|
}
|
|
|
|
public override void OnEnter() {
|
|
DoAction();
|
|
if ( !everyFrame ) {
|
|
Finish();
|
|
}
|
|
}
|
|
|
|
public override void OnUpdate() {
|
|
DoAction();
|
|
}
|
|
|
|
void DoAction() {
|
|
var go = Fsm.GetOwnerDefaultTarget(gameObject);
|
|
if ( UpdateCache(go) ) {
|
|
storeResult.Value = isoRigidbody.velocity.magnitude;
|
|
}
|
|
}
|
|
}
|
|
} // IsoTools.PlayMaker.Actions
|
|
#endif
|