PlayerMovement.cs 488 B

1234567891011121314151617181920
  1. using UnityEngine;
  2. namespace Mirror.Examples.Benchmark
  3. {
  4. public class PlayerMovement : NetworkBehaviour
  5. {
  6. public float speed = 5;
  7. void Update()
  8. {
  9. if (!isLocalPlayer) return;
  10. float h = Input.GetAxis("Horizontal");
  11. float v = Input.GetAxis("Vertical");
  12. Vector3 dir = new Vector3(h, 0, v);
  13. transform.position += dir.normalized * (Time.deltaTime * speed);
  14. }
  15. }
  16. }