Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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
0
Question by SecurityOstrich · Aug 15, 2017 at 01:12 AM · movementmouselookfps controllerjitterjittering

Jittery FPS Camera when moving

I'm writing a basic FPS controller and using the following for mouse look:

 public float sensitivity = 1.0F;
         public float smoothing = 1.0F;
         private float minimumX = -80F;
         private float maximumX = 80F;
         float rotationX = 0F;
         float rotationY = 0F;
         float smoothedX = 0F;
         float smoothedY = 0F;
     
         void Update()
         {
             rotationX += Input.GetAxisRaw("Mouse Y") * sensitivity;
             rotationY += Input.GetAxisRaw("Mouse X") * sensitivity;
     
             rotationX = Mathf.Clamp(rotationX, minimumX, maximumX);
     
             smoothedX = Mathf.Lerp(smoothedX, rotationX, 1.0F / smoothing);
             smoothedY = Mathf.Lerp(smoothedY, rotationY, 1.0F / smoothing);
     
             transform.localEulerAngles = new Vector3(-smoothedX, smoothedY, 0.0f);
         }

I have been stuck for days trying to get my player to rotate in the camera direction so that they can walk forward based on where you look. I have tried many things and all of them result in either the player not turning, or it "working" but having the camera get choppy whenever I move AND rotate at the same time.

I am moving the player like this:

     private void GetInput()
     {
         vInput = Input.GetAxis("Vertical");
         hInput = Input.GetAxis("Horizontal");
         jumpInput = Input.GetAxisRaw("Jump");
     }    
 
     private void Run()
     {
         vel.z = vInput * speed;
         vel.x = hInput * speed;
     }
 
     private void Update()
     {
         GetInput();
         Run();
         Jump();
         rb.velocity = transform.TransformDirection(vel);
     }

Can someone please explain to me how to properly do this setup and how to stop the camera jitter? Both the camera and the player are being rotated in Update() so I don't think they should be out of sync in their movements but I must be misunderstanding something.

Comment
Add comment · Show 3
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 Destolos · Aug 15, 2017 at 09:27 AM 0
Share

I tested your scripts and it worked for me. Good examples for FPS-controller are in the StandardAssets.

avatar image x4637x · Aug 15, 2017 at 11:00 AM 0
Share

Try move rb.velocity = transform.TransformDirection(vel); to FixedUpdate().

avatar image ryisnelly · Sep 07, 2017 at 10:55 AM 0
Share

have you tried disabling V sync?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by kingkdaboss567 · Sep 07, 2017 at 10:51 AM

Try Fixed Update

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
avatar image
0

Answer by Babul2 · Sep 07, 2017 at 12:00 PM

Use "Time.deltaTime"

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
avatar image
0

Answer by EagleDeveloper · Aug 07, 2020 at 08:10 PM

Hey @SecurityOstrich ,

Sorry for the late Reply

Actually, I had the same problem, It actually is very simple.

Just change this:

          rotationX += Input.GetAxisRaw("Mouse Y") * sensitivity * Time.fixedDeltaTime;
          rotationY += Input.GetAxisRaw("Mouse X") * sensitivity * Time.fixedDeltaTime;
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 mazylia5 · Feb 22, 2021 at 01:49 PM 0
Share

I made an account just to thank you for saving my game. Thank you brother Time.deltatime did not work but Time.FixedDetlaTime did Thank you and have a good life.

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

104 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

Related Questions

Jittery camera motion in GearVR when moving camera - nothing seems to work. 2 Answers

Movement jitter every few seconds 1 Answer

First Person Player 3 Answers

FPS controller and mouseLook problem 1 Answer

how do I sync movement with mouselook 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