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

46 lines
930 B
C#

#if PLAYMAKER
using UnityEngine;
using HutongGames.PlayMaker;
using IsoTools.PlayMaker.Internal;
namespace IsoTools.PlayMaker.Actions {
[ActionCategory("IsoTools.Physics")]
[HutongGames.PlayMaker.Tooltip(
"Sets the Mass of a IsoRigidbody.")]
public class IsoSetMass : IsoComponentAction<IsoRigidbody> {
[RequiredField]
[CheckForComponent(typeof(IsoRigidbody))]
public FsmOwnerDefault gameObject;
[RequiredField]
public FsmFloat mass;
public bool everyFrame;
public override void Reset() {
gameObject = null;
mass = 1.0f;
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) ) {
isoRigidbody.mass = mass.Value;
}
}
}
} // IsoTools.PlayMaker.Actions
#endif