Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Brackeys first person tutorial

Hi i was watching Brackeys how to make first person tutorial and i have problem and the problem is the code not working even that its the same as his code i don't know why its not working And just to let you know that I'm using UNITY 2018.4 version And I'm in the 8:14 minute in the video

Here is an image of my unity screen


here is my code ( MouseLook ) script

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

  }

}

Answers

  • HNJHNJ Member

    Delete the empty void Start() and you may have two void Start() and void Update() in MouseLook class.

    And you also have two MouseLook scripts.

  • I am also struggling on this tutorial, but I do know one thing that could help: remove the semi colon right after ("MouseX") and ("MouseY")

  • sing UnityEngine;


    public class cam : MonoBehaviour

    {

      public float speed = 100;

      public Transform playerbody;

      float xr = 0;

      // Start is called before the first frame update

      void Start()

      {

        Cursor.lockState = CursorLockMode.Locked;

      }


      // Update is called once per frame

      void Update()

      {

        float mx = Input.GetAxis("Mouse X") * speed * Time.deltaTime;

        float my = Input.GetAxis("Mouse Y") * speed * Time.deltaTime;

        xr -= my;

        playerbody.Rotate(Vector3.up*mx);

        xr = Mathf.Clamp(xr, -90, 90);

        transform.localRotation = Quaternion.Euler(xr, 0, 0);

      }

    try this

Sign In or Register to comment.