mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-13 15:52:03 +07:00
46 lines
930 B
C#
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
|