GetMass2d.cs 747 B

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