UseGravity.cs 756 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if CHRONOS_PLAYMAKER
  2. using HutongGames.PlayMaker;
  3. namespace Chronos.PlayMaker
  4. {
  5. [ActionCategory("Physics (Chronos)")]
  6. [Tooltip("Sets whether a Game Object's Rigidy Body is affected by Gravity.")]
  7. public class UseGravity : ChronosComponentAction<Timeline>
  8. {
  9. [RequiredField]
  10. [CheckForComponent(typeof(Timeline))]
  11. public FsmOwnerDefault gameObject;
  12. [RequiredField]
  13. public FsmBool useGravity;
  14. public override void Reset()
  15. {
  16. gameObject = null;
  17. useGravity = true;
  18. }
  19. public override void OnEnter()
  20. {
  21. DoUseGravity();
  22. Finish();
  23. }
  24. private void DoUseGravity()
  25. {
  26. var go = Fsm.GetOwnerDefaultTarget(gameObject);
  27. if (UpdateCache(go))
  28. {
  29. timeline.rigidbody.useGravity = useGravity.Value;
  30. }
  31. }
  32. }
  33. }
  34. #endif