First Person Player

Hello I’m creating a game with a First Person Player and am following Brackeys tutorial on First Person Movement: FIRST PERSON MOVEMENT in Unity - FPS Controller - YouTube | but I doesn’t work like Brackeys shows, instead it doesn’t move when the mouse does and moves when holding the RMB it will move even without the code there. Here the code without Y movement
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour
{

public float mouseSensitivity = 100f;

public Transform playerBody;

// Start is called before the first frame update
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

    playerBody.Rotate(Vector3.up * mouseX);
}

}`

Thank anyone in advance

Hello,

There are a few things that could be going wrong. Let’s try them in order:

  1. Are you pressing “Play” to test? I only ask because the mouse does not typically control the camera with the RMB unless you are in the “Scene” view instead of the “Game” view.

  2. Have you attached your MouseLook script to an object in the scene as a Component?

  3. Have you attached the Player Object Transform to the MouseLook script (filling the field for the “playerBody” variable)?

One thing to try is to see your mouseX value by exposing a Debug Value field to the Unity Inspector. Declare the Debug variable up top and use public, then link it to the mouseX value in Update():

public class MouseLook: MonoBehavior {
public float DebugMouseX; //Delete me later

void Update()
{
    float mouseX ...
    DebugMouseX = mouseX;

This will allow you to debug its value by looking at the Component in your scene while you’re in Game View, to make sure it is changing as expected. (You can accomplish the same thing via Debug.Log(mouseX), but it is a bit messier in the console.)

Let me know if none of those fixes work.

-Jason

Okay so, I was already doing the First 3 things correctly and the Debug value works however it displays as 0 at all times. I’m wondering if it has something to do with the Render Pipeline or because I’m running a newer version.

It is picking it up now and if giving me results other that zero but it is still not moving.

Hi

I’m having this issues myself but there was no conclusion to this post

Im getting the error message

Assets/Assests to use/Utility/SimpleActivatorMenu.cs(11,16): error CS0619: ‘GUIText’ is obsolete: ‘GUIText has been removed. Use UI.Text instead.’

This is my coding from Brackeys tutorial

Thanks

Cal

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

public class MouseLook : MonoBehaviour
{


	public float mouseSensitivity = 100f;

	public Transform playerBody;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
		float mouseX = Input.GetAxis("Mouse X"); * mouseSensitivity * Time.deltaTime;
		float mouseY = Input.GetAxis("Mouse Y"); * mouseSensitivity * Time.deltaTime;

		playerBody.Rotate(Vector3.up * mouseX);
	}
}