Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

problems with my fps controller

Discussion in 'Scripting' started by jonahvendraws, Apr 2, 2021.

  1. jonahvendraws

    jonahvendraws

    Joined:
    Mar 30, 2021
    Posts:
    42
    I just need to know what is wrong with this script because for some reason its giving me these errors:

    Assets/movement.cs(24,54): error CS0103: The name 'mouseSensitivity' does not exist in the current context

    UnexpectedEnumValueException`1: Value Unknown of enum Source is unexpected.


    unity version: 2020.3.2f1

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class movement : MonoBehaviour
    6. {  
    7.  
    8.     [SerializeField] Transform playerCamera = null;
    9.  
    10.     void Start()
    11.     {
    12.        
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.         UpdateMouseLook();
    18.     }
    19.  
    20.     void UpdateMouseLook()
    21.     {
    22.         Vector2 mouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
    23.  
    24.         transform.Rotate(Vector3.up * mouseDelta.x * mouseSensitivity);
    25.     }
    26. }
    27.  
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,697
    You never declared a variable called
    mouseSensitivity
    so of course you cannot use it on line 24.
     
    Joe-Censored likes this.
  3. jonahvendraws

    jonahvendraws

    Joined:
    Mar 30, 2021
    Posts:
    42
    seems simple, thanks
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336