Why doesn't my character walk smoothly?

fallenshoeboxfallenshoebox Posts: 3Member

https://gfycat.com/FrankSnappyBug

That is what happens when I press and hold either walking button. My character jolts forward a short distance, then stops, then proceeds to walk smoothly from then on.

It's a RigidBody2D in Character mode. Here's my walk logic:

if Input.is_action_pressed("move_left"):
    set_linear_velocity(Vector2(-walkSpeed, lv.y))

Any help would be appreciated.

Answers

  • curly-bracecurly-brace Posts: 13Member

    i think would be more obvious if you could create the basic empty project that demonstrates this. because there could be an issue in control setup or node setup or other code, that you think shouldn't make troubles.. and it even possible that while creating such a project you will understand the cause yourself. if not, post link here and we will see.

  • fallenshoeboxfallenshoebox Posts: 3Member
    edited November 2016

    @curly-brace said:
    i think would be more obvious if you could create the basic empty project that demonstrates this. because there could be an issue in control setup or node setup or other code, that you think shouldn't make troubles.. and it even possible that while creating such a project you will understand the cause yourself. if not, post link here and we will see.

    Okay, I made a new project, recreated the bare essentials, and stripped the script of everything but the basic movement logic and it's still doing the same thing.

    https://gfycat.com/AmbitiousCircularLaughingthrush

    Here's the whole script:

  • fallenshoeboxfallenshoebox Posts: 3Member
    edited November 2016

    Accidentally split the post because I am dumb.

  • PaulMurrayPaulMurray Posts: 26Member
    Answer ✓

    Have you tried hard-coding in a speed decrease, so your starting value is always 0?

    From the first clip you posted it looks like the old value is still being decreased when you change direction. So you set the left move velocity to -300, but the old value is still trying to return to zero first, which is overriding your velocity momentarily, causing the juttering.

    Once it's reset the velocity stays at the -300 as requested.

  • puppetmasterpuppetmaster Posts: 5Member
    Answer ✓

    It's because you don't use the delta value.

Sign In or Register to comment.