Skip to content

Instantly share code, notes, and snippets.

@reneweiser
Last active March 2, 2020 11:44
Show Gist options
  • Save reneweiser/ef4a4fc11859574cb5fece81f6f8ba98 to your computer and use it in GitHub Desktop.
Save reneweiser/ef4a4fc11859574cb5fece81f6f8ba98 to your computer and use it in GitHub Desktop.
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