Home > Blockchain >  No option to input value in Unity?
No option to input value in Unity?

Time:04-20

I tried to follow a Brackeys Unity Tutorial, but I can't seem to get it to work. With this script I should have an option to change the Value of Mouse Sensitivity and to add an object to the Player Body to transform it. But I see neither of those.

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);
    }
}

CodePudding user response:

Hard to answer without more context, however a few things come to mind.

Is your script on a GameObject in the scene?
Is the field playerBody assigned? The field is public and not assigned in the script itself.
The axis might not be set up for some reason, check the AxisManager in Unity to make sure they receive input, you can log their values with Debug.Log(Input.GetAxis("Mouse X"));.

If you provide more context it would be easier to tell what is going wrong, preferably the Log after starting the scene and a screenshot of the Inspector of the GameObject with the assigned script in the scene.

CodePudding user response:

Have you attached the script to a game object in the scene?

Not much information is given but I would assume your script isn't being called as its not attached to any game objects in the scene.

Drag and drop the script to your desired game object, I believe in your case would be the player? or something attached or related to the player?

  • Related