Hi there!
I am very new to unity and I’m trying to create a third person game. my character can move normally but I don’t know how to make it so you move in the direction that the camera is facing.
This is my character controller:
public class ThirdPersonMovement2 : MonoBehaviour
{
public Rigidbody rb;
public float ForwardForce = 100f;
public float SidewaysForce = 100f;
public float BackwardsForce = 100f;
void Update()
{
if (Input.GetKey("w"))
{
rb.AddForce (0, 0, ForwardForce);
}
if (Input.GetKey("a"))
{
rb.AddForce (-SidewaysForce, 0, 0);
}
if (Input.GetKey("d"))
{
rb.AddForce (SidewaysForce, 0, 0);
}
if (Input.GetKey("s"))
{
rb.AddForce (0, 0, -ForwardForce);
}
}
}
the player itself is a parent object that has a rigidbody, a capsule collider and the script, with a child object that has all of the graphics of the player.
please help me because I have no idea how to make the character move in the direction of the camera and I would really like to make this work.