Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 superlol · Dec 07, 2010 at 12:04 AM · charactercontrollercamera-movementjitter

jittering when moving

Hiall!

I'm new in scripting and i'm approacing step by step, tutorial by tutorial and headache by headache :)...ok let me explain my problem.

I'm doing a simple test, with a character moving on a plane, and the camera that follow the character only on sliding (mmm...like zelda!), then I added a little smooth to the camera with the mathf.lerp, here is my code:

//smoothfollow camera script var target : Transform; var distance = 3.0; var slide = 2.0; var heightDamping = 10; var rotationDamping = 3.0;

function Update () { // Early out if we don't have a target if (!target) return;

 // Calculate the current rotation angles
 //wantedRotationAngle = target.eulerAngles.y;
 wantedSlidex = target.position.x;
 wantedSlidez = target.position.z - 5;

 //currentRotationAngle = transform.eulerAngles.y;
 currentSlidex = transform.position.x;
 currentSlidez = transform.position.z;

 // Damp the rotation around the y-axis
 //currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);

 // Damp the height
 currentSlidex = Mathf.Lerp (currentSlidex, wantedSlidex, heightDamping * Time.deltaTime);
 currentSlidez = Mathf.Lerp (currentSlidez, wantedSlidez, heightDamping * Time.deltaTime);

 // Convert the angle into a rotation
 //currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);

 // Set the position of the camera on the x-z plane to:
 // distance meters behind the target
 transform.position.z = currentSlidez;
 transform.position.y = target.position.y +2;
 //transform.position -= target.position * distance;

 // Set the height of the camera
 transform.position.x = currentSlidex;

 // Always look at the target
 transform.LookAt (target);

}

and here my moving script:

var speed = 10; var gravity = 20.0;

private var moveDirection = Vector3.zero;

function FixedUpdate() { var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) {

     moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
     Input.GetAxis("Vertical"));

     if (moveDirection != Vector3.zero) {
         var rotation = transform.rotation; 
         rotation.SetLookRotation(moveDirection); 
         transform.rotation = rotation;
     }

     moveDirection *= speed;

 }

 if (Input.GetButton ("Jump")) {
         moveDirection.y = 3;
 }


 // Apply gravity
 moveDirection.y -= gravity * Time.deltaTime;

 // Move the controller
 controller.Move(moveDirection * Time.deltaTime);

}

@script RequireComponent(CharacterController)

The problem is that the character is perfect in movement but the background shakes a bit with a terrible jitter...you can see th problem directly downloading the .exe project.

Any suggestion or semplification to my code will be accepted :D...

Project exe download: http://rapidshare.com/files/435362527/lolworlds.exe

Thank's a lot!

Comment
Add comment · Show 4
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 superlol · Dec 08, 2010 at 12:28 AM 0
Share

UPDATE!!!

http://rapidshare.com/files/435574410/lolworlds.rar

correct link for download the exe :D

avatar image aeroson · Sep 28, 2013 at 01:19 PM 0
Share

If you want it to look smooth and updated every frame, do use Update ins$$anonymous$$d of FixedUpdate

avatar image magma · Aug 30, 2014 at 08:01 PM 0
Share

I had the player and camera set to FixedUpdate and was still seeing jitter on the player. I noticed this only occurred when forces were applied to the player via my input control script.

To fix this, I set the rigidbody on the player to "Interpolate: None" and the problem completely went away.

avatar image Molgore · Sep 23, 2014 at 03:23 AM 0
Share

THAN$$anonymous$$ YOU!!!!! I have been having the jitters for days now....finally this rehab worked :)

3 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by Proclyon · Dec 07, 2010 at 12:10 AM

Hmm I remember a thingy about that, no idea if it helps but definatly worth a try I think. It's a mode on the rigidbody settings that just like your title says has "jerkiness"/"jittering" same same.

Here's the quote:

Interpolate Try one of the options only if you are seeing jerkiness in your Rigidbody's movement.

None: No Interpolation is applied.

Interpolate: Transform is smoothed based on the Transform of the previous frame.

Extrapolate Transform is smoothed based on the estimated Transform of the next frame.

Hope it helps :)

Comment
Add comment · Show 9 · 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 superlol · Dec 07, 2010 at 10:07 AM 0
Share

Hi Proclyon thanks for the interest :)...unfortunately it seems that the case you explain doesn't solve my problem, cause i'm not using a rigidbody on my character and there's any interpolate option in the charactercontroller.

Thanks again!

avatar image Proclyon · Dec 07, 2010 at 10:28 AM 0
Share

Hmm sorry to hear that, and you are most welcome :) I don't know if I can see the problem elsewhere. But what I usually do is try to cut down the scope of the problem by commenting bits and pieces or look back at the design ( which if well made cuts down debugging and problem times to an infinitesimal value )

avatar image superlol · Dec 08, 2010 at 07:24 PM 2
Share

SOLVED :D...after talkin with a programmer he told me that maybe the problem was in the sync...and he was right! I changed the update of the script camera from "update" to "fixedupdate" and now it seems to work correctly! Thank's anyway for the support and suggestions! Stay tuned on my progress eheh :)

avatar image Proclyon · Dec 08, 2010 at 09:42 PM 0
Share

wow that's superweird. FixedUpdate is specifically designed for being used for rigidbody and physics stuff. Well whatever works huh :D

avatar image owenpat · Mar 05, 2011 at 05:37 PM 0
Share

I just had the same problem and found this. Yes -- the Player on FixedUpdate and Camera on Update was the problem. Changing the camera to also FixedUpdate got rid of the jitter.

Show more comments
avatar image
-1

Answer by Mohamed Adly · Oct 29, 2014 at 03:19 PM

Change the value of the FPS using the following code

Application.targetFrameRate = 50;

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 lulubiceps · Mar 08, 2021 at 10:05 PM

I've had the exact same issue with Cinemachine. Crazy shaking screen. Thanks for your tips I was able to fix it. If anyone has the same issue specificly with cinemachine, go to your Cinemachine Brain component and change Update Method to fixedUpdate. It should work like a charm !

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

10 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

Related Questions

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

Why is my camera rotating like crazy? 2 Answers

1st person camera with 3rd person model? 0 Answers

Camera falls to the ground while I run 0 Answers

How do I fix Camera stuttering in first person? 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