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 Alsaw · Jun 16, 2020 at 07:35 PM · jitter

Parallax background is jittery while camera follows player

Hello, I'm having an issue where the background is jiitery while camera is following the player. The character is correctly displayed (no blurry no jitter). I've tried many solutions but nothing works. The jitter is still present.


Here is my player movement script :

 private float move;
 public bool controlsEnabled;
 Rigidbody2D rigidbody2d;
 private float maxSpeed = 5f;
 
   void Update()
     {
         if (controlsEnabled) {
             move = Input.GetAxis("Horizontal");
         }
     }
     private void FixedUpdate() {
    
             rigidbody2d.velocity = new Vector2(move * maxSpeed, rigidbody2d.velocity.y);
      }



I'm using pixel perfect camera > 32 PPU (ref res X 480 Y 320) alt text Cinemachine brain with Fixed Update for the Update Method. (with cinemachine pixel perfect extension) All sprites are imported with good practices for 2D pixel art, I mean Point (no filter) etc...


Here is my parallax script for the background :

 public class Parallax : MonoBehaviour {
 
     private float length, startpos;
     public GameObject cam;
     public float parallaxEffect;
 
 
     
     // Start is called before the first frame update
     void Start()   {
         startpos = transform.position.x;
         length = GetComponent<SpriteRenderer>().bounds.size.x;
         
     }
 
     // Update is called once per frame
     void FixedUpdate()
     {
         float temp = (cam.transform.position.x * (1 - parallaxEffect));
         float dist = (cam.transform.position.x * parallaxEffect);
         transform.position = new Vector3(startpos + dist, transform.position.y, transform.position.z);
 
         if (temp > startpos + length) startpos += length;
         else if (temp < startpos - length) startpos -= length;
 
     }
 }

I've tested pixel perfect camera version 2.0.3 & 3.0.2. Did anyone meet the same issue ?

Thanks

cinemachine.png (29.5 kB)
Comment
Add comment
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

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Kalavun · Jan 16, 2021 at 05:38 PM

I'm not sure if it is a good solution or not but in my case when I'm put parallax code in FixedUpdate solved the problem.

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
0

Answer by N-8-D-e-v · Jun 20, 2020 at 09:04 PM

Put your camera follow script in LateUpdate(), it will update after the player has moved then

Comment
Add comment · Show 4 · 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 Alsaw · Jun 21, 2020 at 12:31 PM 0
Share

Hello, Thanks for your reply. I tried to put the cinemachine brain in LateUpdate() or even try with the following script, but the jitter is still present.

public class CameraFollow : $$anonymous$$onoBehaviour {

  public float dampTime = 0f;
  private Vector3 velocity = Vector3.zero;
  public Transform target;
 
  // Update is called once per frame
  void LateUpdate() {

      
      if (target)
      {
     
          Vector3 destination = new Vector3(target.position.x , transform.position.y, -10);
          transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
      }
  
  }

}

avatar image N-8-D-e-v Alsaw · Jun 21, 2020 at 03:14 PM 0
Share

Is your player object interpolating? That is a common source of jittery cameras

avatar image Alsaw N-8-D-e-v · Jun 21, 2020 at 06:24 PM 0
Share

Interpolate is set to none, not sure if it's the good setting

alt text

rigidbody.png (17.0 kB)
Show more comments
avatar image
0

Answer by RobertSbruno · May 18, 2021 at 08:53 AM

Static player and camera that follows the player. Player is the only stationary object in this game. Parallax background and foreground. Objects such as monsters, obstacles and loot which are set to move at equal speed relative to the ground. A pool manager that collects all objects that moved out of the screen.

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 RobertSbruno · May 18, 2021 at 07:08 AM

Static player and camera that follows the player. Player is the only stationary object in this game. Parallax background and foreground. Objects such as monsters, obstacles and loot which are set to move at equal speed relative to the ground. A pool manager that collects all objects that moved out of the screen.

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 myazuid · Nov 18, 2021 at 08:32 PM

Hello, did you solve this? I have the exact same problem at the minute!

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

130 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

Related Questions

Enemy Jitters When Following 0 Answers

Damp Camera rotation caused by Animations 1 Answer

Physics + first person camera = jitter? 4 Answers

Can't Find Optimization Problem in My Scripts 4 Answers

Physics in non-inertial reference frame resulting in jitter movement 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