My hero won't face the direction he's moving...

I’ve tried various lookAt & Vector3 rotation code and can’t seem to figure it out how to get my character facing the direction he’s moving. Can someone please help out?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace DeepWolf.HungerThirstSystem.Examples
{
    [RequireComponent(typeof(CharacterController))]
    public class SimpleMovement : MonoBehaviour
    {
        [SerializeField] private float _moveSpeed = 5.0f;

        /// <summary>
        /// The extra amount that is going to be added to the hunger increase amount, when moving.
        /// </summary>
        [Tooltip("The extra amount that is going to be added to the hunger increase amount.")]
        [SerializeField] private float _extraHungerIncreaseAmount;

        /// <summary>
        /// The extra amount that is going to be added to the thirst increase amount, when moving.
        /// </summary>
        [Tooltip("The extra amount that is going to be added to the thirst increase amount.")]
        [SerializeField] private float _extraThirstIncreaseAmount;

        private Vector3 _moveDirection;
        private CharacterController _characterController;
        private bool _isMoving;

        private void Awake()
        {
            _characterController = GetComponent<CharacterController>();
        }

        private void Update()
        {
            _moveDirection.Set(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
            if (_moveDirection.sqrMagnitude > 0.1f)
            {
                _moveDirection = _moveDirection.normalized;
                if (!_isMoving)
                {
                    _isMoving = true;
                    OnMoveStarted();
                }
            }
            else
            {
                if (_isMoving)
                {
                    _isMoving = false;
                    OnMoveStopped();
                }
            }

            _moveDirection *= _moveSpeed;
            _moveDirection = transform.TransformDirection(_moveDirection);

            _characterController.SimpleMove(_moveDirection);
        }

        /// <summary>
        /// Triggered when start moving
        /// </summary>
        private void OnMoveStarted()
        {
            HungerThirst hungerThirst = GetComponent<HungerThirst>();
            // Add extra hunger increase amount
            hungerThirst.AddExtraHungerIncreaseAmount(_extraHungerIncreaseAmount);
            // Add extra thirst increase amount
            hungerThirst.AddExtraThirstIncreaseAmount(_extraThirstIncreaseAmount);
        }

        /// <summary>
        /// Triggered when stop moving
        /// </summary>
        private void OnMoveStopped()
        {
            HungerThirst hungerThirst = GetComponent<HungerThirst>();
            // Remove the extra hunger increase amount
            hungerThirst.ReduceExtraHungerIncreaseAmount(_extraHungerIncreaseAmount);
            // Remove the extra thirst increase amount
            hungerThirst.ReduceExtraThirstIncreaseAmount(_extraThirstIncreaseAmount);
        }
    }
}

Can’t you just set his rotation’s euler angles?

The simplest way is to simply set the forward vector of your transform to the same as the move direction.

_characterController.SimpleMove(_moveDirection);
transform.forward = _moveDirection

Unfortunately this doesn’t work as expected. The character turns wildly and is unstable…

Show us how you’re doing it

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace DeepWolf.HungerThirstSystem.Examples
{
    [RequireComponent(typeof(CharacterController))]
    public class SimpleMovement : MonoBehaviour
    {
        [SerializeField] private float _moveSpeed = 5.0f;
        [SerializeField] private float _rotateSpeed = 5.0f;

        /// <summary>
        /// The extra amount that is going to be added to the hunger increase amount, when moving.
        /// </summary>
        [Tooltip("The extra amount that is going to be added to the hunger increase amount.")]
        [SerializeField] private float _extraHungerIncreaseAmount;

        /// <summary>
        /// The extra amount that is going to be added to the thirst increase amount, when moving.
        /// </summary>
        [Tooltip("The extra amount that is going to be added to the thirst increase amount.")]
        [SerializeField] private float _extraThirstIncreaseAmount;

        private Vector3 _moveDirection;
        private CharacterController _characterController;
        private bool _isMoving;

        private void Awake()
        {
            _characterController = GetComponent<CharacterController>();
        }

        private void Update()
        {
            _moveDirection.Set(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
            transform.forward = _moveDirection * _rotateSpeed;
            if (_moveDirection.sqrMagnitude > 0.1f)
            {
                _moveDirection = _moveDirection.normalized;
                if (!_isMoving)
                {
                    _isMoving = true;
                    OnMoveStarted();
                }
            }
            else
            {
                if (_isMoving)
                {
                    _isMoving = false;
                    OnMoveStopped();
                }
            }

            _moveDirection *= _moveSpeed;
            _moveDirection = transform.TransformDirection(_moveDirection);
           
            _characterController.SimpleMove(_moveDirection);
            transform.forward = _moveDirection;
        }

        /// <summary>
        /// Triggered when start moving
        /// </summary>
        private void OnMoveStarted()
        {
            HungerThirst hungerThirst = GetComponent<HungerThirst>();
            // Add extra hunger increase amount
            hungerThirst.AddExtraHungerIncreaseAmount(_extraHungerIncreaseAmount);
            // Add extra thirst increase amount
            hungerThirst.AddExtraThirstIncreaseAmount(_extraThirstIncreaseAmount);
        }

        /// <summary>
        /// Triggered when stop moving
        /// </summary>
        private void OnMoveStopped()
        {
            HungerThirst hungerThirst = GetComponent<HungerThirst>();
            // Remove the extra hunger increase amount
            hungerThirst.ReduceExtraHungerIncreaseAmount(_extraHungerIncreaseAmount);
            // Remove the extra thirst increase amount
            hungerThirst.ReduceExtraThirstIncreaseAmount(_extraThirstIncreaseAmount);
        }
    }
}

Can you please assist?