You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
637 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RemotePlayer : Player {
  5. public Animator Animator;
  6. private float walkSpeed;
  7. private Vector3 lastPosition;
  8. public void Start()
  9. {
  10. lastPosition = transform.position;
  11. }
  12. protected override void Update()
  13. {
  14. DoAnimation();
  15. base.Update();
  16. }
  17. private void DoAnimation()
  18. {
  19. Vector3 dir = lastPosition - transform.position;
  20. lastPosition = transform.position;
  21. Animator.SetFloat("WalkSpeed", dir.magnitude);
  22. transform.forward = dir.normalized;
  23. }
  24. }