Need help with my controller key binds

Nothing really matched my issue

I’m new to controller and started using unity early this year so could this be beginner friendly because I don’t make games very often. I need help making unity detect my buttons I’m pressing on my controller. I’ve got the movement set up though.

This is what my code looks like:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 5f;  // Movement speed
    public float lookSpeedX = 2f; // Mouse look speed on the X-axis (horizontal)
    public float lookSpeedY = 2f; // Mouse look speed on the Y-axis (vertical)

    public bool Sprint = false;

    public Camera playerCamera;
    private float rotationX = 0f;

    void Start()
    {
        // Get the camera attached to the player object
        playerCamera = GetComponentInChildren<Camera>();

        // Lock and hide the cursor to prevent it from leaving the game window
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    void Update()
    {
        // First, handle mouse look
        float mouseX = Input.GetAxis("Mouse X") * lookSpeedX;
        float mouseY = Input.GetAxis("Mouse Y") * lookSpeedY;

        // Rotate player horizontally based on mouseX
        transform.Rotate(Vector3.up * mouseX);

        // Rotate camera vertically based on joystick, but limit the up/down rotation
        rotationX -= mouseY;
        rotationX = Mathf.Clamp(rotationX, -75f, 75f); // Prevent camera from flipping upside down
        playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);

        // Then handle movement (WASD)
        float moveX = Input.GetAxis("Horizontal"); // Left/Right
        float moveZ = Input.GetAxis("Vertical");   // Forward/Backward

        Vector3 moveDirection = transform.right * moveX + transform.forward * moveZ;

        // Apply the movement in the world space
        transform.Translate(moveDirection * moveSpeed * Time.deltaTime, Space.World);
    }
}

There is no way you can’t find information on how to set up gamepad inputs.

There’s information for the old system in the manual: Unity - Manual: Handle Game Controller input

And tons of information on the new input system: Quickstart Guide | Input System | 1.11.2

If you are unsure how to change what controls what, then you have moved too far and too fast and you have skipped Step #2 below.

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.

You need to work one small step at a time, without moving on until you understand 100% of what you have done so far, which might involve going back to review earlier parts you did. If you cannot do this, we certainly cannot do it for you.

Imphenzia: How Did I Learn To Make Games: