Search Unity

Smooth 2d movement - impossible?

Discussion in '2D' started by Wolk, Jun 12, 2018.

  1. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    Hello, i'm trying to get a smooth 2d movement, but all attempts so far have failed me.
    I get a feeling of the object jumping and not moving smoothly. The camera is static, rb2d settings are set to interpolate, and physics fixed timestep is set to 0.033, Application.targetFrameRate = 60 and vsync to every blank.
    Here's a video. The only code used is
    GetComponent<Rigidbody2D>().AddForce(transform.up * 15f, ForceMode2D.Impulse);

    Here's a video of the movement.

     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Can you describe more specifically what isn't smooth? It looks pretty good to me, but I'm not sure if I'm looking for the right thing. I don't see any jumping.
     
  3. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    The arrows leave a "trail" behind them, it's really apparent when it's in fast motion, as is on the right. It's skipping places and jumping sporadically and it just doesn't feel/look good. I want to know how to have a smooth fast movement that looks like the object is going fast. Even the one on the left doesn't feel "smooth". Maybe it has something to do with the shape of the arrow
     
  4. SuperCrow2

    SuperCrow2

    Joined:
    Mar 8, 2018
    Posts:
    584
    Not seeing it. Looks fine to me. Could be yt quality isn't good enough to pick it up. Can you take screenshots of it and post the images here?
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Screenshots can't possibly show the issue, since it relies entirely on motion...screenshots will just show 3 normal-looking arrows.

    Anyway, some of the issue is probably that your monitor has a poor response time. For me, the slower arrow is basically fine—very faint ghosting if you look really close—but the faster one has somewhat of the issue you're talking about (I played the video using the 1080p60fps setting). This is partially due to the high contrast and my monitor having OK but not great response time, but also that 60fps just isn't all that great, and this is a good way of showing the limitations. In any case, there's no skipping or jumping at all, so I don't know where that's coming from on your end.

    The proper fix would be a decent gaming monitor with a good response time and a 120Hz or 144Hz refresh rate. (Related, don't use targetFrameRate and vsync at the same time; not all monitors are 60Hz.) Failing that, your monitor probably has some kind of overdrive setting that you can try, which reduces trailing at the cost of other artifacts. However, I tried different AMA settings on mine, and it didn't have any noticeable effect for this particular case. Also, yes, a different graphic—less contrast, maybe include a motion blur trail—would help.

    --Eric
     
    MisterSkitz likes this.
  6. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    The faster you go, the more pixels you skip each frame... eventually you're going to just see the arrow pop along because it's moving so fast that it jumps more pixels than the arrow is long in a frame. To compensate for that you'd need to add some sort of motion blur, or simply add a trail to the arrow when it's going fast to help smooth over the frame by frame jumps for the eyes
     
    MisterSkitz likes this.
  7. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    Has nothing to do with the display rate, without Application.targetFrameRate = 60, it's even more jittery. I'm just wondering why/how this happens to objects that are relatively fast. I wonder if you can have bullets or arrows that look decent in unity at all now
     
  8. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    are you adding the force in Update() or FixedUpdate()?
     
  9. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    Honestly it doesn't matter because it's only added once. I've tried movement with force being added in fixed update and it exhibits the same behavior.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It has a lot to do with it; Antony-Blackett and I explained the issue. It's not Unity.

    --Eric
     
  11. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    In that case, what would be the best possible option to achieve the smoothest movement?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Try the suggestion above about adding a motion-blur trail to the graphic.

    --Eric
     
  13. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    I can't, i'm doing this for a mobile game and pp is really expensive.
    Was wondering about settings and/or any other tricks
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No...add a motion-blur trail to the graphic. Literally. No image effects or anything.

    --Eric
     
  15. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    What is the final goal? Why do you need fast objects? How many will there be?
     
  16. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    The goal is to have an object move fast over some obstacles. In order to have the feeling you're in control, it's a lot nicer if you can actually follow the object with your eyes
     
  17. eriknastesjo

    eriknastesjo

    Joined:
    Aug 16, 2018
    Posts:
    13
    Any luck finding solution? Judging from your video (the trail is REALLY apparent on my 4k screen) I got the exact same problem . Starting to suspect that the key is to play around with contrasting colors and speed but if there are any "setting-solution" I would like to know. Also gonna look into how to add motion-blurr...
     
  18. Wolk

    Wolk

    Joined:
    Jul 12, 2014
    Posts:
    59
    @eriknastesjo nope, but i have noticed that changing the shape of the object does help a lot. Also having things move slower relative to your screen helps. Wish someone figured it out :)
     
    eriknastesjo likes this.