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
4
Question by user-1770 (google) · Mar 21, 2010 at 07:38 PM · camerasmooth

First Person Camera is extremely jerky

In the official island demo the First person Camera has extremely jerky movement which I've never been able to figure out. I've trawled the forums for days not believing that I'm the only one to notice this or have the issue. All the demos utilising the FPS script exhibit this problem.

The closest answer I've found is to put all all camera movement into FixedUpdate. Which I think I did, but no change. I edited all the scripts Mouselook, FPSWalker etc to use FixedUpdate. Is that the right thing to do? It made no difference to the poor camera movement. Could someone explain how to implement a solution to get a smooth FPS camera result in a demo.

Coming from Blitz3D I'd implement a smoothing queue or damping etc. I just refuse to believe this technology is demoed with such a rubbish camera script and movement, please let me into the secret.

Comment
Add comment · Show 2
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 Lo0NuhtiK · Dec 14, 2011 at 06:22 AM 0
Share

1.4k views, and the question only got ONE vote so far... lol wtf?

avatar image flannerus · Dec 14, 2011 at 04:56 PM 0
Share

yeah personally it says my account can't upvote it....not sure if only ad$$anonymous$$s can...but that wouldn't make sense...agreed though, this is a really useful thread if you're making an FPS game...

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Eric5h5 · Mar 21, 2010 at 08:04 PM

Must be something in your system, because there's nothing jerky about it here or on any other computer I've used. Putting a first-person camera script in FixedUpdate is not the right thing to do...that will make it only update when the physics system updates, instead of every frame. Try turning off any mouse hacks or utilities you might be using.

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 flannerus · Dec 13, 2011 at 08:42 PM 0
Share

FixedUpdate is often the culprit when the FPS controller feels jerky, deselecting it solved a fairly annoying choppiness for me.

avatar image
2

Answer by bruno martelli_legacy · Apr 17, 2010 at 09:05 PM

maybe its the computer thats running a bit slow?

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
2

Answer by Leocesar · Nov 27, 2011 at 04:54 AM

Searching the forums I found the following script and it solved my FPS camera movement (I’ve made some adaptations to the original script to fit my needs. Sorry, I don't know who the author is).

     using UnityEngine;
 
 using System.Collections;
 
 using System.Collections.Generic;
 
 
 
 public class SmoothMouseLook : MonoBehaviour
 
 {
 
     /*
 
     This script is used to average the mouse input over x 
 
     amount of frames in order to create a smooth mouselook.
 
     */
 
 
 
     //Mouse look sensitivity
 
     public float sensitivityX = 2f;
 
     public float sensitivityY = 2f;
 
 
 
     //Default mouse sensitivity
 
     public float defaultSensX = 2f;
 
     public float defaultSensY = 2f;
 
 
 
     //Minimum angle you can look up
 
     public float minimumY = -60f;
 
     public float maximumY = 60f;
 
     
 
     //Number of frames to be averaged, used for smoothing mouselook
 
     public int frameCounterX = 35;
 
     public int frameCounterY = 35;
 
     
 
     //Mouse rotation input
 
     private float rotationX = 0f;
 
     private float rotationY = 0f;
 
     
 
     //Used to calculate the rotation of this object
 
     private Quaternion xQuaternion;
 
     private Quaternion yQuaternion;
 
     private Quaternion originalRotation;
 
 
 
     //Array of rotations to be averaged
 
     private List<float> rotArrayX = new List<float> ();
 
     private List<float> rotArrayY = new List<float> ();
 
 
 
     void Start ()
 
     {
 
         //Lock/Hide cursor
 
         Screen.lockCursor = true;
 
         
 
         if (rigidbody)
 
             rigidbody.freezeRotation = true;
 
         
 
         originalRotation = transform.localRotation;
 
     }
 
 
 
     void Update ()
 
     {
 
         if (Screen.lockCursor) {
 
             //Mouse/Camera Movement Smoothing:    
 
             //Average rotationX for smooth mouselook
 
             float rotAverageX = 0f;
 
             rotationX += Input.GetAxis ("Mouse X") * sensitivityX;
 
             
 
             //Add the current rotation to the array, at the last position
 
             rotArrayX.Add (rotationX);
 
             
 
             //Reached max number of steps?  Remove the oldest rotation from the array
 
             if (rotArrayX.Count >= frameCounterX) {
 
                 rotArrayX.RemoveAt (0);
 
             }
 
             
 
             //Add all of these rotations together
 
             for (int i_counterX = 0; i_counterX < rotArrayX.Count; i_counterX++) {
 
                 //Loop through the array
 
                 rotAverageX += rotArrayX[i_counterX];
 
             }
 
             
 
             //Now divide by the number of rotations by the number of elements to get the average
 
             rotAverageX /= rotArrayX.Count;
 
             
 
             //Average rotationY, same process as above
 
             float rotAverageY = 0;
 
             rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
 
             rotationY = ClampAngle (rotationY, minimumY, maximumY);
 
             rotArrayY.Add (rotationY);
 
             
 
             if (rotArrayY.Count >= frameCounterY) {
 
                 rotArrayY.RemoveAt (0);
 
             }
 
             
 
             for (int i_counterY = 0; i_counterY < rotArrayY.Count; i_counterY++) {
 
                 rotAverageY += rotArrayY[i_counterY];
 
             }
 
             
 
             rotAverageY /= rotArrayY.Count;
 
             
 
             //Apply and rotate this object
 
             xQuaternion = Quaternion.AngleAxis (rotAverageX, Vector3.up);
 
             yQuaternion = Quaternion.AngleAxis (rotAverageY, Vector3.left);
 
             transform.localRotation = originalRotation * xQuaternion * yQuaternion;
 
         }
 
     }
 
 
 
     private float ClampAngle (float angle, float min, float max)
 
     {
 
         if (angle < -360f)
 
             angle += 360f;
 
         if (angle > 360f)
 
             angle -= 360f;
 
         
 
         return Mathf.Clamp (angle, min, max);
 
     }
     }


Steps to use it: Add a First Person Controller to the scene and remove the Mouse Look script all together 1) Attach Smooth Mouse Look to the Character Controller with this parameters:

Sensitivity X: 4 Sensitivity Y: 0 Default Sens X: 4 Default Sens Y: 0 Minimum Y: 0 Maximum Y: 0 Frame Counter X: 20 Frame Counter Y: 20

2) Attach another Smooth Mouse Look to the Main Camera with this parameters:

Sensitivity X: 0 Sensitivity Y: 5 Default Sens X: 0 Default Sens Y: 5 Minimum Y: -60 Maximum Y: 60 Frame Counter X: 20 Frame Counter Y: 20

That’s it!

Comment
Add comment · Show 3 · 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 flannerus · Dec 13, 2011 at 08:45 PM 0
Share

Reeeeaaally awesome script here, I've found that lowering the Frame Counter to about 12 makes for a much less "floaty" feel. Wish I could upvote (dunno why it wont let me) because this script will be integral to my game.

avatar image Leocesar · Dec 14, 2011 at 06:14 AM 0
Share

The value used in FrameCounter depends on the effect you are trying to achieve. For a underwater or slow motion situation 20 to 25 will convey the right feel. And 12 is a good number for a normal FPS. I felt it also and updated my game to use "12" and it's really better this way. Thanks to test it out flannerus.

avatar image sphere312 · Jun 26, 2014 at 08:01 AM 0
Share

Helpful follow-up comment regarding 12 as the frame counter, which was much smoother than 20 for me. 20 felt too "floaty" for my purposes. Thanks!

avatar image
0

Answer by Anthony.du · Jul 12, 2010 at 07:58 PM

I have the exact same problem as the person wrote above. I once had Unity on an old machine and it was a bit jumpy then. I now have a Core i3 computer with Intel HD graphics and it is very jerky. I have gone through all the graphics settings but it hasn't changed anything.

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 flannerus · Dec 13, 2011 at 08:43 PM 0
Share

Try deselecting "FixedUpdate" on the $$anonymous$$ain Camera.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The sprite that is being followed by thr camera is very jittery and doesn't look very nice at all. 2 Answers

How can I Make my orbit camera more smooth? 2 Answers

Rotate around object smoothly 1 Answer

Smooth camera rotation velocity. 0 Answers

How do I stop Smooth.LookAt, so I can move freely? 0 Answers


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