How to make my object go in the direction its facing [C#]

I have a basic movement and rotation code, but I want it to go in the direction that the cube is facing. Could someone help me?

using UnityEngine;
using System.Collections;

public class Player_Controll : MonoBehaviour
{
private CharacterController controller;

public float jumpForce;
public float moveForce;

private Vector3 Move_Vector;
private Vector3 LastMove;
private float gravity = 14f;
private float verticalvelocity;

private Transform CamTrans;

private void Start()
{
    controller = GetComponent<CharacterController>();
}

private void Update()
{
    CharacterControll();
}

private void CharacterControll()
{
    if (controller.isGrounded)
    {
        verticalvelocity = -1;

        if (Input.GetKeyDown(KeyCode.Space))
        {
            verticalvelocity = jumpForce;
        }
    }
    else
    {
        verticalvelocity -= gravity * Time.deltaTime;
        
    }

    Vector3 MoveVector = Vector3.zero;
    transform.Rotate(0, Input.GetAxis("Horizontal") * MoveSpeed * 50 * Time.deltaTime, 0);
    MoveVector.y = verticalvelocity;
    MoveVector.z = Input.GetAxis("Vertical") * moveForce;
    controller.Move(MoveVector * Time.deltaTime);
}

}

Doing

	Vector3 MoveVector = Vector3.zero;
	transform.Rotate(0, Input.GetAxis("Horizontal") * MoveSpeed * 50 * Time.deltaTime, 0);
	MoveVector.y = verticalvelocity;
	MoveVector.z = Input.GetAxis("Vertical") * moveForce * transform.forward.z;
	MoveVector.x = Input.GetAxis("Vertical") * moveForce * transform.forward.x;
	controller.Move(MoveVector * Time.deltaTime);
}``

seems to work.

when working with physics (rigedBody) you should use the velocity, MoveTranslation and MoveRotation Method within the FixedUpdate instead of the “normale” transform.

I’m not sure how the CharacterController works but you could go back to basic and try to move the character with:

MoveVector.y = verticalvelocity;
float speed=Input.GetAxis("Vertical") * moveForce;
float radians=transform.rotation.eulerAngles.y * Mathf.Deg2Rad;
MoveVector.x = Mathf.Sin(radians) * speed;
MoveVector.z = Mathf.Cos(radians) * speed;
controller.Move(MoveVector * Time.deltaTime);

The Cos and Sin might need to get switched if it doesn’t work this way.

Kind regards,

Yorick