Move player forward where the camera facing

Hi! I’m not that new to programming but for Unity, I’m a newbie.
I’m trying to create a TPS mobile game, but I can’t achieve to the player move where the camera facing.
This is my code so far:

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

public class InputHandler : MonoBehaviour {
    public Animator animator;
    private float speedPercentChanged;
    public Transform playerTransform;
    public FixedJoystick Joystick1;
    public Vector2 moveJoystick;

    void Update () {
        float speedPercent;
        moveJoystick = Joystick1.inputVector;
        if (Mathf.Abs(moveJoystick.y) < Mathf.Abs(moveJoystick.x))
            speedPercent = Mathf.Abs(moveJoystick.x);
        else
            speedPercent = Mathf.Abs(moveJoystick.y);
        animator.SetFloat("speedPercent", speedPercent);
        if (moveJoystick.x != 0 && moveJoystick.y != 0)
        {
            Vector3 movement = new Vector3(moveJoystick.x, 0.0f, moveJoystick.y);
            playerTransform.rotation = Quaternion.LookRotation(movement);
            playerTransform.Translate(movement * (5 * speedPercent) * Time.deltaTime, Space.World);
        }
       
    }
}

I can’t find any posts that has the solution for this. (All the post used something else than transform.Translate)

You want to multiply your direction by the rotation.
I think its just player rotation * direction (quaternion must come first)

I used this for a PC RTS, I’ll double check the code when I get home

I can’t really understand where I have to multiply that 2 value. I tried it in the Translate function as well where I set the movement value.

I just added this line to my code:

movement = Camera.main.transform.TransformDirection(movement);

AND IT’S WORKING.
Thanks for your help.

Glad you got it working, the transform direction does pretty much the same thing i believe.

this is the code i was talking about for the RTS

        CamRigY.position += Quaternion.Euler(0,CamRigY.eulerAngles.y,0)
            * new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"))
            *  moveSpeed
            * Time.deltaTime;