Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / PlayerMovement.cs
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerMovement: MonoBehaviour
  5. {
  6. public CharacterController ch;
  7. public Animator animator;
  8. public float moveSpeed = 3;
  9. public float rotateSpeed = 3;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. ch = GetComponent<CharacterController>();
  14. //animator = GetComponent<Animator>();
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. float horizontal = Input.GetAxis("Horizontal");
  20. float vertical = Input.GetAxis("Vertical");
  21. /*if(vertical != 0)
  22. {
  23. animator.SetTrigger("Run", true);
  24. }
  25. else
  26. {
  27. animator.SetTrigger("Run", false);
  28. }*/
  29. //if (Input.GetKey(KeyCode.Mouse1)) animator.SetTrigger("Atack", true);
  30. //else animator.SetTrigger("Atack", false);
  31. ch.SimpleMove(moveSpeed * vertical* transform.forward );
  32. transform.Rotate(0, rotateSpeed*horizontal * Time.deltaTime, 0);
  33. }
  34. }