How To Change Direction WASD Moves Depending On Camera Rotation (888769)

Hi! I have a game in which a character moves in first person using WASD, and the camera rotation is controlled by the mouse. The problem is that the character moves based on the XYZ coordinates, and not the camera’s rotation. How do I make it so that W moves the player forward based on the direction the camera is facing?

Here is my code connected to the camera:

using UnityEngine;
using System.Collections;
public class FirstPersonCam : MonoBehaviour
{
public float speedH = 2.0f;
public float speedV = 2.0f;
private float yaw = 0.0f;
private float pitch = 0.0f;
void Update ()
{
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
}

Here is my code connected to the player:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collide : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetComponent<Rigidbody>().velocity = new Vector3 (Input.GetAxis("Horizontal") * 5, 0, Input.GetAxis("Vertical") * 5);
}
}

I’m new to Unity, so sorry if this is a stupid question.

Check out the DemoCameraRotatedControls scene in my Proximity Buttons project.

Relevant code:

https://github.com/kurtdekker/proximity_buttons/blob/master/proximity_buttons/Assets/DemoCameraRotatedControls/RotatedControlsPlayerController.cs

Look around line 124 to 130

proximity_buttons is presently hosted at these locations:

https://bitbucket.org/kurtdekker/proximity_buttons

https://github.com/kurtdekker/proximity_buttons

https://gitlab.com/kurtdekker/proximity_buttons

https://sourceforge.net/projects/proximity-buttons/

Thanks for your answer! As I said, I’m very new to Unity, so I was wondering where and what I would put into my code, as I don’t know what anything does on there.