Search Unity

Resolved Sprites blurred while moving - with Cinemachine

Discussion in 'Editor & General Support' started by xDayhawk, Aug 28, 2020.

  1. xDayhawk

    xDayhawk

    Joined:
    Jun 24, 2020
    Posts:
    57
    Hi,

    I'm a Unity Beginner, started out about 2 months ago. Seen a lot of guides, and built a few projects (with the guildes), now i'm trying to build my own basic 2D platformer, and i've encountered a weird issue regarding movement.

    The issue is - when i'm moving my Player char, it seems like the Sprite is getting blurred, the faster i move it the more blurry it looks, its hard to see but hopefully you can spot it with these two clips:



    What i've tried so far:
    1. Using 2 different sprites - no animation, the animator is off, so its 1 sprite renderer image with no changes.
    2. Used 3 different move methods, velocity, set position and MovePosition, all 3 are showing the same symptoms...
    3. Tried putting it in FixedUpdate when using veolocity since its a rigidbody usage
    4. Tried change deltaTime to fixedDeltaTime

    Could this be related to frames?
    I feel like its a Frames issue, i have a 144mhz screen, dont know if it affects anything.

    This is the code i'm using (what's excluded in comments is the Animator and the other move types i've used which are MovePosition and Velocity:

    Code (CSharp):
    1.     void Update()
    2.     {
    3.         Run();
    4.     }
    5.  
    6.     private void FixedUpdate()
    7.     {
    8.      
    9.     }
    10.  
    11.     private void Run()
    12.     {
    13.         float deltaX = Input.GetAxis("Horizontal");
    14.         //Vector2 newPosition = new Vector2(deltaX, transform.position.y);
    15.         //Vector2 newp = newPosition.normalized * runSpeed;
    16.         if (deltaX != 0)
    17.         {
    18.             Flip(deltaX);
    19.             //animator.SetBool("isWalking", true);
    20.             transform.position = new Vector3(transform.position.x + (deltaX * runSpeed * Time.deltaTime), transform.position.y, transform.position.z);
    21.             //myRigidbody2D.velocity = new Vector2(deltaX * runSpeed * Time.deltaTime, myRigidbody2D.velocity.y);
    22.             //myRigidbody2D.MovePosition(myRigidbody2D.position + newp * Time.fixedDeltaTime);
    23.         }
    24.         //else
    25.             //animator.SetBool("isWalking", false);
    26.     }

    Thanks in advance,
     
    Last edited: Aug 28, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Maybe im not as observant.. but I don't see any blur. Could it be ghosting on your monitor? Im watching the video on my phone (pixel 4a)
     
  3. xDayhawk

    xDayhawk

    Joined:
    Jun 24, 2020
    Posts:
    57
    I dont think its that easy to see on that vid.
    i have 2 monitors, 1 is a plain 1080p with 60mhz, and its also visible there..

    its driving me crazy :D
     
  4. xDayhawk

    xDayhawk

    Joined:
    Jun 24, 2020
    Posts:
    57
    I wanted to update on the status of this issue if there's a chance it will help any1 out there.

    I left this issue behind and i encountered it in another game i was making, only this time i noticed that it started to appear after i added Cinemachine, i switch to cine from a personal script i wrote for camera movement... with this lead i continued to investigate and i found an answer!

    if your movement or other psychics related code is under the fixedUpdate method, then you need to change the Cinemachine brain (on your main camera) to fixedUpdate:
    upload_2020-12-30_22-26-23.png
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    The Smart Update setting on the Cinemachine Brain is supposed to use FixedUpdate automatically if the target has a non-interpolating Rigidbody.
     
  6. xDayhawk

    xDayhawk

    Joined:
    Jun 24, 2020
    Posts:
    57
    my player char is a 2D sprite with a Rigidbody 2D and the Interpolate is set to None, that's how its always been.
    i've added a Cinemachine and a 2D virtual camera, those were the settings on the Brain, and my movement was always on fixedUpdate...

    i'm just happy i found the solution, thank you for your comment mate i actually wasnt aware of that Interpolate option on the rigidbody! i still consider myself a new unity dev.
     
  7. derjul31

    derjul31

    Joined:
    Sep 8, 2021
    Posts:
    1
    Thank you! This fixed it for me
     
  8. Cayon

    Cayon

    Joined:
    Oct 23, 2021
    Posts:
    1
    Thank you kind man, this worked for me
     
    Asanyth likes this.
  9. battlevoli

    battlevoli

    Joined:
    May 23, 2022
    Posts:
    1
    had the exact same issue. Worked for me!
     
  10. KaseyW

    KaseyW

    Joined:
    Jun 6, 2013
    Posts:
    30
    Thank you for the update, I tried so many different things but this 100% fixed my issues.
     
  11. strictfp

    strictfp

    Joined:
    Jul 29, 2020
    Posts:
    13
    Can confirm the same fix.
     
  12. joeavanzato

    joeavanzato

    Joined:
    Mar 12, 2023
    Posts:
    1
    Worked for me as well, thanks :)
     
  13. Asanyth

    Asanyth

    Joined:
    Mar 12, 2023
    Posts:
    3
    You are a true hero...Thank you so much for coming back to give an update. Your post is still helping people 10 years later <3
     
  14. serdarsyg_

    serdarsyg_

    Joined:
    Sep 5, 2023
    Posts:
    1
    You are a life saver bro. Thank you so much :).