How to make player move based on camera direction?

Here is my current code for player movement:

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

public class PlayerController : MonoBehaviour {

    public float speed = 10;

    private Rigidbody rig;

    // Use this for initialization
    void Start ()
    {
        rig = GetComponent<Rigidbody>();
    }
 
    // Update is called once per frame
    void Update ()
    {
        float hAxis = Input.GetAxis("Horizontal");
        float vAxis = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(hAxis, 0, vAxis) * speed * Time.deltaTime;

        rig.MovePosition(transform.position + movement);
    }
}

As of now my camera could be facing backwards and he still moves along axis

Thanks for any answers :slight_smile:

I don’t quite understand your question, plus use transform.translate instead of moveposition if you want to calculate physics in your movement

sorry i don’t quite understand, i am just trying to make my character walk in the direction that my camera is facing, should i also include the camera code?