Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by unity_Vpi53N_fb99F6g · Jan 05, 2020 at 04:51 PM · noobcharacter movementjittery

Fps Camera rotation very choppy and jittery

I'm extremely new to unity, and I'm trying to make a simple character controller with a rigidbody, but my camera movement is so extremely laggy.

 void Look()
     {
         //Gets the mouse input and multiplies it by the sensitivity
         float horizontal = Input.GetAxis("Mouse X") * sensitivity;
         float vertical = Input.GetAxis("Mouse Y") * sensitivity;
 
         //Variable which keeps track of the rotation of the camera on the y
         yClamp += vertical;
 
         //Rotates the camera and player
         camera.transform.Rotate(-Vector3.right * vertical);
         transform.Rotate(Vector3.up * horizontal);
 
         //Prevents the camera from rotating upside down
         if(yClamp >= 90)
         {
             Clamp(camera.transform, 270, "x");
             vertical = 0;
             yClamp = 90;
         }
         else if (yClamp <= -90)
         {
             Clamp(camera.transform, 90, "x");
             vertical = 0;
             yClamp = -90;
         }
     }
 
     //Clamps the rotation of a given transform on the given axis by the given number
     void Clamp(Transform obj, float value, string axis)
     {
         Vector3 eulerAngles = obj.eulerAngles;
 
         switch (axis)
         {
             case "x":
                 eulerAngles.x = value;
                 break;
 
             case "y":
                 eulerAngles.y = value;
                 break;
         }
 
         obj.eulerAngles = eulerAngles;
     }

Any help is appreciated, thanks 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 pineco222 · Nov 13, 2021 at 02:14 PM 0
Share

Do you use call Look()? In update or FixedUpdate. Do you get stutter when you move character and mouse in the same time?

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by RendrWyre · Jan 05, 2020 at 06:38 PM

Updating camera movement should be done in LateUpdate().


https://docs.unity3d.com/ScriptReference/MonoBehaviour.LateUpdate.html


"LateUpdate is called after all Update functions have been called. This is useful to order script execution. For example a follow camera should always be implemented in LateUpdate because it tracks objects that might have moved inside Update."

Comment
Add comment · Show 5 · 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 unity_Vpi53N_fb99F6g · Jan 06, 2020 at 07:54 PM 0
Share

I tried your solution, but sadly the problem persits. Thanks anyway!

avatar image RendrWyre unity_Vpi53N_fb99F6g · Jan 07, 2020 at 10:45 PM 1
Share

"I've been testing some stuff and I've come to the conclusion that it's not about the script, but a problem with unity"

There's no issue with Unity and if you are using LateUpdate() for the camera then the issue is somewhere else. You don't have your camera as a child of the player, for example? that would cause issues. or, if you are trying to use the HDRP with a low/mid range rig you will also have issues. (even in a blank scene). Have you tried downloading the Standard Assets from the asset store and testing the default player controller to see if it still lags?

avatar image unity_Vpi53N_fb99F6g RendrWyre · Jan 10, 2020 at 04:06 PM 0
Share

Srry :P I'm kinda new so I have no clue how unity works. I'll repost the code

Show more comments
avatar image
2

Answer by tashfiq103 · Jan 08, 2020 at 01:11 AM

Hey, would you mind sharing the code that you used to rotate the camera for your game? :)

@unity_Vpi53N_fb99F6g

Comment
Add comment · Show 1 · 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 unity_Vpi53N_fb99F6g · Jan 10, 2020 at 04:07 PM 0
Share

Okay done :)

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

126 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

Related Questions

Stutter / Glitchy running character 1 Answer

Argument out of range 1 Answer

what did i do wrong?,what did I do wrong 1 Answer

ENEMY MOVEMENT SCRIPT 0 Answers

m_MouseLook.LookRotation After Quaternion.LookRotation on some object 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