Switch movement of the player

Hey all!

I’ve been searching since yesterday evening for a solution to my problem.

Keep in mind I’m still a beginner :slight_smile:

I think I build my scene the wrong way around, because when I press W the player goes right, etc.
I have tried rotating the game object the player is in, but that didn’t work.

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

public class PlayerController : MonoBehaviour
{
    public float moveSpeed;
    public float jumpForce;

    private Rigidbody rig;





    void Awake()
    {
        rig = GetComponent<Rigidbody>();
    }

    private void Update()
    {
        Move();

        if(Input.GetButtonDown("Jump"))
        {
            TryJump();
        }
    }

    void Move()
    {
        float zImput = Input.GetAxis("Horizontal");
        float xImput = Input.GetAxis("Vertical");

        Vector3 dir = new Vector3(xImput, 0, zImput) * moveSpeed;
        dir.y = rig.velocity.y;

        rig.velocity = dir;

        Vector3 facingDir = new Vector3(xImput, 0, zImput);

        if (facingDir.magnitude > 0)
        {
            transform.forward = facingDir;
        }
    }

    void TryJump ()
    {
        Ray ray = new Ray(transform.position, Vector3.down);

        if (Physics.Raycast(ray, 1,5))
        {
            rig.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        }
    }

}

How can I change the direction my player is moving.

Did a workaround by changing the keys assigned in the Project Settings. Works perfectly.