GetMass.cs 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if CHRONOS_PLAYMAKER
  2. using HutongGames.PlayMaker;
  3. namespace Chronos.PlayMaker
  4. {
  5. [ActionCategory("Physics (Chronos)")]
  6. [Tooltip("Gets the Mass of a Game Object's Rigid Body.")]
  7. public class GetMass : ChronosComponentAction<Timeline>
  8. {
  9. [RequiredField]
  10. [CheckForComponent(typeof(Timeline))]
  11. [Tooltip("The GameObject that owns the Rigidbody")]
  12. public
  13. FsmOwnerDefault gameObject;
  14. [RequiredField]
  15. [UIHint(UIHint.Variable)]
  16. [Tooltip("Store the mass in a float variable.")]
  17. public FsmFloat storeResult;
  18. public override void Reset()
  19. {
  20. gameObject = null;
  21. storeResult = null;
  22. }
  23. public override void OnEnter()
  24. {
  25. DoGetMass();
  26. Finish();
  27. }
  28. private void DoGetMass()
  29. {
  30. var go = Fsm.GetOwnerDefaultTarget(gameObject);
  31. if (UpdateCache(go))
  32. {
  33. storeResult.Value = timeline.rigidbody.mass;
  34. }
  35. }
  36. }
  37. }
  38. #endif