SetMass2d.cs 725 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if CHRONOS_PLAYMAKER
  2. using HutongGames.PlayMaker;
  3. namespace Chronos.PlayMaker
  4. {
  5. [ActionCategory("Physics 2d (Chronos)")]
  6. [Tooltip("Sets the Mass of a Game Object's Rigid Body 2D.")]
  7. public class SetMass2d : ChronosComponentAction<Timeline>
  8. {
  9. [RequiredField]
  10. [CheckForComponent(typeof(Timeline))]
  11. public FsmOwnerDefault gameObject;
  12. [RequiredField]
  13. [HasFloatSlider(0.1f, 10f)]
  14. public FsmFloat mass;
  15. public override void Reset()
  16. {
  17. gameObject = null;
  18. mass = 1;
  19. }
  20. public override void OnEnter()
  21. {
  22. DoSetMass();
  23. Finish();
  24. }
  25. private void DoSetMass()
  26. {
  27. if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) return;
  28. timeline.rigidbody2D.mass = mass.Value;
  29. }
  30. }
  31. }
  32. #endif