Last active
March 2, 2020 11:44
-
-
Save reneweiser/ef4a4fc11859574cb5fece81f6f8ba98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class BasicFpMover : MonoBehaviour | |
{ | |
private CharacterController _characterController; | |
private Vector3 _moveDirection; | |
[SerializeField] private float _speed = 6f; | |
private void Awake() | |
{ | |
_characterController = GetComponent<CharacterController>(); | |
} | |
private void Update() | |
{ | |
_moveDirection = transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal"); | |
_moveDirection *= _speed; | |
_characterController.Move(_moveDirection * Time.deltaTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment