Topic was automatically imported from the old Question2Answer platform.
Asked By
Robster
Old Version
Published before Godot 3 was released.
Hi all,
Here is my move:
func move(speed, acc, delta):
#lerp interpolates smoothly between a source number (first value) and a destination number (Second value) by weight (last value)
current_speed.x = lerp(current_speed.x , speed, acc * delta)
set_linear_velocity(Vector2(current_speed.x,get_linear_velocity().y))
When my character moves left and right it does the following:
Moving right the VERTICAL (Y) velocity hovers to around - .008
Moving left the VERTICAL (Y) velocity hovers to around + .008
This is causing havoc with my jump animation as it uses something like:
Just recreated your project as best I could from the snippets you provided, and ran into the y-float problem you described. Was able to solve it by setting the friction property to zero in either the rigidbody2d or static body ground plane.
Thank you ericdl.
I already had friction set to 0 on the character’s RidigBody2D.
I then changed the friction to 0 on the ground’s StaticBody2D as it was set to 1.
Unfortunately the exact behavior is still happening. I was super excited when I read your solution. Shame it didn’t work. But it must be a guide to what is needed to fix it.
Robster | 2016-08-20 03:16
Sorry it didn’t work. Did you play around with all of the other property values in the editor for the rigidbody2d and staticbody2d?
ericdl | 2016-08-20 03:23
Is there by chance a way I can privately send you the file to look at? It’s very small and focused.
Robster | 2016-08-20 03:26
Sure, you can send it to (email removed) and I will take a look.
ericdl | 2016-08-20 03:33
This is an update for anyone with this issue in the future.
ericdl was kind enough to look at my code. He couldn’t find a reason it was happening but offered the following workarounds:
Workaround #1: ignore tiny y-values.
In func air_state(delta)
changed if get_linear_velocity().y > 0:
to if get_linear_velocity().y > 1:
and changed elif get_linear_velocity().y < 0:
to elif get_linear_velocity().y < -1:
Workaround #2: zero out tiny y-values.
In func move(speed, acc, delta):
add the line if abs(get_linear_velocity().y) < 1: set_linear_velocity(Vector2(get_linear_velocity().x,0))
Either workaround can be used alone, or they can be used together, makes no difference…
(Thank you Eric for helping find a workaround to this problem)