Files
unity-iso-tools/Assets/IsoTools/Addons/PlayMaker/Actions/IsoGetMass.cs

47 lines
1006 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 Mass of a IsoRigidbody and stores it in a Float Variable.")]
public class IsoGetMass : 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.mass;
}
}
}
} // IsoTools.PlayMaker.Actions
#endif