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.

41 lines
922 B

4 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerController : MonoBehaviour
  5. {
  6. public float walkSpeed;
  7. private Vector2 receivedInput;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. }
  12. public void SetMovement(Vector2 input)
  13. {
  14. receivedInput = input;
  15. }
  16. public void UpdatePosition()
  17. {
  18. float RunnerX, RunnerZ;
  19. RunnerZ = Input.GetAxisRaw("Vertical");
  20. RunnerX = Input.GetAxisRaw("Horizontal");
  21. //float rotateTo = RotateRunner(RunnerX, RunnerZ);
  22. RunnerZ = Input.GetAxis("Vertical") * Time.deltaTime * walkSpeed;
  23. RunnerX = Input.GetAxis("Horizontal") * Time.deltaTime * walkSpeed;
  24. transform.Translate(RunnerX, 0, RunnerZ);
  25. }
  26. // Update is called once per frame
  27. void Update()
  28. {
  29. UpdatePosition();
  30. }
  31. }