PlayerAbilityPathFollow.cs 742 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using UnityEngine;
  3. public class PlayerAbilityPathFollow : CharacterState
  4. {
  5. public override void Start()
  6. {
  7. base.Start();
  8. this.pm = this.pab.GetComponent<PlatformMovement>();
  9. }
  10. public override void FixedUpdate()
  11. {
  12. base.FixedUpdate();
  13. this.HandleCarry();
  14. }
  15. private void HandleCarry()
  16. {
  17. if (this.pAttr.isOnGround)
  18. {
  19. GameObject groundGameObject = this.pm.GetGroundGameObject();
  20. if (groundGameObject != null)
  21. {
  22. PathFollow component = groundGameObject.GetComponent<PathFollow>();
  23. if (component != null)
  24. {
  25. Vector3 v = component.CurrentSpeed * Time.fixedDeltaTime;
  26. this.pm.position += (Vector2)v;
  27. }
  28. }
  29. }
  30. }
  31. public PlatformMovement pm;
  32. }