Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added lerp for smooth transition of walk speed #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andersmmg
Copy link

No description provided.

@selgesel selgesel added the enhancement New feature or request label Jul 23, 2024
Copy link
Owner

@selgesel selgesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for the super late reply, and thanks a lot for the contribution!

Added some notes regarding the lerp step and indentations, but otherwise looks pretty good, thanks!

player.anim_tree.set("parameters/OnGround/blend_position", player.horizontal_velocity.length() / 10.0)
# set the checked ground blend position to player's horizontal speed divided by 10, the running speed
# lerp for smooth blending
var new_blend_pos = lerp(player.anim_tree.get("parameters/OnGround/blend_position"), player.horizontal_velocity.length() / 10.0, 0.1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While playing with your changes on my (very choppy) Mac I found the hardcoded 0.1 lerp step to cause a little bit of jerkiness. 10.0 * delta worked much more smoothly, so can you please use that instead?

# set the checked ground blend position to player's horizontal speed divided by 10, the running speed
# lerp for smooth blending
var new_blend_pos = lerp(player.anim_tree.get("parameters/OnGround/blend_position"), player.horizontal_velocity.length() / 10.0, 0.1)
player.anim_tree.set("parameters/OnGround/blend_position", new_blend_pos)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change the indentation of the affected lines from tabs to spaces? You can do that by selecting the 4 affected lines and hitting Ctrl+i or Cmd+i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants