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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Trying to follow Brackey's First Person Movement tutorial, and it's too slow

Discussion in 'Scripting' started by XenSakura, May 1, 2021.

  1. XenSakura

    XenSakura

    Joined:
    Feb 23, 2021
    Posts:
    2
    Hi there,
    I was following Brackey's First person movement tutorial on youtube, but I've found it's far too slow. here's the code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class MouseLook : MonoBehaviour
    6. {
    7.     public float mouseSensitivity = 100f;
    8.     public Transform playerBody;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.        
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    19.         float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    20.        
    21.         playerBody.Rotate(Vector3.up * mouseX);
    22.     }
    23. }
    Did I do something wrong, or has the unity game engine changed and I just need to use a different method?
     
  2. XenSakura

    XenSakura

    Joined:
    Feb 23, 2021
    Posts:
    2
    Nevermind, it turns out the default sensitivity in the input manager was set to 0.1 for some reason.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Glad you're back online. Remember for issues like this, the first stop should be lots of Debug.Log() statements.

    To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run?
    - what are the values of the variables involved? Are they initialized?

    Knowing this information will help you reason about the behavior you are seeing.

    If you are running a mobile device you can also see the console output. Google for how.