Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by The-Captain-Moo · Jan 07, 2020 at 05:43 AM · scripting problemmovementmouselookfps controller

First Person Player

Hello I'm creating a game with a First Person Player and am following Brackeys tutorial on First Person Movement: https://www.youtube.com/watch?v=_QajrabyTJc | 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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lgarczyn · Jan 07, 2020 at 08:53 PM 0
Share

Please use the 101010 button to correctly format code.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by JasonBennett · Jan 07, 2020 at 05:13 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image The-Captain-Moo · Jan 08, 2020 at 01:24 AM 0
Share

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.

avatar image JasonBennett The-Captain-Moo · Jan 08, 2020 at 08:34 PM 0
Share

Huh, weird. Try Debug.Log(Input.GetAxis("$$anonymous$$ouse X");

to see if you're getting any input at all

avatar image
0

Answer by The-Captain-Moo · Jan 09, 2020 at 03:46 AM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JasonBennett · Jan 17, 2020 at 07:52 PM 0
Share

Could you post a screenshot of your inspector with the object highlighted that has the script on it?

avatar image The-Captain-Moo · Jan 18, 2020 at 12:02 AM 0
Share

Sorry I can't because I've deleted the files for it but thank you for your help.

avatar image
0

Answer by calgraham545 · Apr 26, 2020 at 02:26 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

255 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Jittery FPS Camera when moving 3 Answers

How to restrict first person from turning 360 degrees when sitting? 1 Answer

Change standart FirstPersonController variables via other script 2 Answers

FPS Controller rotation,FPS Controller rotation problem 0 Answers

FPS controller and mouseLook problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges