Search Unity

Can't get "smooth" 2D pixel movement? Am I missing something or is this a Unity issue? (iPhone)

Discussion in '2D' started by emde, Aug 2, 2015.

  1. emde

    emde

    Joined:
    Aug 1, 2015
    Posts:
    6
    Looking for some help from an experienced 2D developer!

    I’m new to Unity and testing a few things out for a 2D pixel game. I’ve noticed that my test project exhibits a bit of choppiness/motion blur/frame skipping, I’ve played with various settings and have not been able to find a solution. I'm testing on an iPhone 6, so there shouldn’t by any resource issues.

    For my test, I compared the movement of the infamous flappy bird scroller, using two sprites from the game. In my test you simply tap and the bird goes up. I’ve posted a copy of the project below:

    https://www.dropbox.com/s/pxlulphkhtp771t/Smooth-bird-test.zip?dl=0

    A few notes:

    * Tap and hold the screen to make the bird go up, does this seem choppy to you? It’s almost as if the sprite is skipping frames?

    * To jump I’m using "RigidBody2d.velocity = new Vector2 (0, 135);" in the Update() method. This is the correct method for this type of movement from the tutorials I've gone through so far.

    * I’m using an orthographic camera with a size of 128. Sprites are set to a pixels per unit of 1. I’m shooting for a “game” resolution of 144 x 256, the same as flappy bird.

    * I've played with point and bilinear filtering on the sprites, doesn’t seem to affect it, just the quality(sharpness) of the rendered sprite.

    I did a screen recording of flappy bird vs this app via quick time. Looking at the recording frame by frame, I noticed that the sprite movement of the bird in flappy bird is about 3-4 pixels. In this app it jumps as much as 10+. It is almost as if the sprite movement is at a lower frame rate than the game is running at (60fps?) - like it is not as "smooth".

    I must be missing something here, but it's not obvious to me. Any help is appreciated!

    Thanks
    -emde
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Set Application.targetFrameRate to 60; the default is 30. Physics updates at 50fps by default, which doesn't match the screen update rate.

    --Eric
     
  3. emde

    emde

    Joined:
    Aug 1, 2015
    Posts:
    6
    Eric, you are amazing. I added this and everything is SUPER SMOOTH now. You are the man! Seriously want to buy you a beer now. I'm PM'ing you an amazon gift card brother :)
     
    DeLait, MoonJellyGames and Fcaldas like this.