Hello Guest

Author Topic: Moving sprites seems ' jumpy'  (Read 5811 times)

Theia123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Moving sprites seems ' jumpy'
« on: July 18, 2013, 03:06:28 pm »
I created a 2D game with an 3D camera with a couple of sprites in it. After finishing the tasks, you can move to the next scene. I am then moving the sprites out of the camera view, and the new ones into the camera view. However, when moving the sprites, they don't move in a smooth way. It feels like they are redrawing each time. The movement is not that fast at all, and I've tested it with less sprites. Also checked the frame rate, which looked very stable. I feel like this has something to do with tk2d, anybody knows a solution?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Moving sprites seems ' jumpy'
« Reply #1 on: July 18, 2013, 08:39:26 pm »
This almost certianly isn't because of tk2d. Pretty sure you'd see the same thing if you replaced the sprites with a box - there isn't anything special about the sprites, they're just meshes on gameobjects like boxes. Are you vsynced? Also if on iOS, are you running at 60hz?

antman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Moving sprites seems ' jumpy'
« Reply #2 on: October 12, 2013, 01:39:01 am »
This is a very strange issue that I seem to be having too!  My FPS seems very consistent -- and this happens when only moving one of my sprites, which is certainly not taxing the draw distance.

I'm using a Coroutine that is basically working like this:

Code: [Select]
while (true) {
    float speed = -1f;
    float dist = speed * Time.deltaTime;
    Vector3 lP = transform.localPosition;
    transform.localPosition = new Vector3(0, lP.y + dist, lP.z);
    yield return null;
}

Wondering why this is giving me the jerky movement too!


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Moving sprites seems ' jumpy'
« Reply #3 on: October 12, 2013, 01:00:56 pm »
First thing to do is try and narrow this down. Try it with a Unity box rescaled to fit the sprite size, is it jerky?

antman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Moving sprites seems ' jumpy'
« Reply #4 on: October 14, 2013, 02:06:34 am »
@unikronsoftware So I tried this with just a Cube and was surprised to find that it was jerky too (I had attempted this before in a tutorial with Unity GameObjects and thought that I was using the Time.deltaTime to smooth the motion correctly).

OK so, it seems that I am just fundamentally getting something wrong with the way that the Coroutine / Time.deltaTime  is moving my game objects (as per my code snippet)  which is why I'm getting jerky motion in my GameObjects (2dtk and otherwise).

A lot of people seem to have had this issue as I search for an answer, however I can't really figure out where I'm going wrong here... hopefully someone can tell me where Im messing this up fundamentally  :(

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Moving sprites seems ' jumpy'
« Reply #5 on: October 14, 2013, 10:55:12 am »
Its likely because Time.deltaTime isn't perfectly smooth. Its producing correct results over time, but not necessary the correct results visually. The funny thing is a lot of people have had the issue, but some have never seen it - as you can tell from the discussions on answers.unity3d.com. You will be able to find a lot of potential solutions - which fix it for some people but not others. I don't know of something that DEFINITELY gets rid of it - I suggest digging through all the unity forum / answers posts you can find. There are a lot of suggestions flying about, and perhaps one of them will fix it for you?