Code (CSharp): using UnityEngine; public class miscare : MonoBehaviour { [SerializeField] private string horizontalInputName; [SerializeField] private string verticalInputName; [SerializeField] private float movementSpeed; private CharacterController charController; private void Awake() { charController = GetComponent<CharacterController>(); } private void Update() { PlayerMovement(); } private void PlayerMovement() { float vertInput = Input.GetAxis(verticalInputName) * movementSpeed; float horizInput = Input.GetAxis(horizontalInputName) * movementSpeed; Vector3 forwardMovement = transform.forward * vertInput; Vector3 lateralMovement = transform.right * horizInput; charController.SimpleMove(forwardMovement + lateralMovement); } }
What isn't working? Do you get an error message? Please edit your post and add code-tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
Then it works perfectly. If you think it behaves wrongly, what's the intended behaviour, and what's the actual behaviour?
Have you attached the script to your character controller gameObject? Is there any change in the transform of character controller gameObject?