Files
beyond/Assets/ThirdParty/PlayMaker/Actions/Physics/SetMass.cs
2024-11-20 15:21:28 +01:00

40 lines
766 B
C#

// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Sets the Mass of a Game Object's Rigid Body.")]
public class SetMass : ComponentAction<Rigidbody>
{
[RequiredField]
[CheckForComponent(typeof(Rigidbody))]
public FsmOwnerDefault gameObject;
[RequiredField]
[HasFloatSlider(0.1f,10f)]
public FsmFloat mass;
public override void Reset()
{
gameObject = null;
mass = 1;
}
public override void OnEnter()
{
DoSetMass();
Finish();
}
void DoSetMass()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (UpdateCache(go))
{
rigidbody.mass = mass.Value;
}
}
}
}