Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

2D walking animation lagging in game

Discussion in '2D' started by bcli, Dec 16, 2014.

?

2D walking animation lagging in game

  1. What is this?

    0 vote(s)
    0.0%
  2. What is this "possible responses", werid.

    1 vote(s)
    100.0%
Multiple votes are allowed.
  1. bcli

    bcli

    Joined:
    Dec 13, 2014
    Posts:
    2
    Hi, guys,
    I created a set of 28 frames 2D walking animation for my character, all of them are 600 * 600 px.
    They were imported as a 3600*3600 px sprite sheet and cut by sprite editor.
    The filter mode is bilinear, and the max size is set to 4096, compressed.
    Then I import the frame sprites to animation controller, and set sample to 35.
    The animation works fine (no frame lose) when I test it, when the character is at the same place.
    But when I move the character in the game (arrow keys), the walking animation start to lag,
    I've notice that unity skipped some of the frames of the animation, which gives me a big headache.
    Can anyone give me a suggestion how to correct this?
    Big thanks guys!
     
  2. bcli

    bcli

    Joined:
    Dec 13, 2014
    Posts:
    2
    I figured it out. It's because I used rigid body.velocity to move the character, which is the most common method showed in tutorials. And then one thing, I need to set the rigid body 2D -> interpolate to interpolate, so unity can do a pre-frame rigid body check,.
     
    theANMATOR2b likes this.
  3. leyend1000

    leyend1000

    Joined:
    Jul 14, 2016
    Posts:
    2
    old question but, how did you move your 2d character without velocity?
     
  4. TheFancyOtter

    TheFancyOtter

    Joined:
    May 10, 2018
    Posts:
    21
    You can use transform.translate which moves it directly instead of adding acceleration