-
Notifications
You must be signed in to change notification settings - Fork 210
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
Walk/run animation blending #1947
Conversation
2021-12-06.18-31-24.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me.
Will test
Device: Issues: 1-Walk to run is smooth now but run to walk appears quite instantaneous and a bit jerky. run.walk.intant.mp42-Walk to run is smooth as whole but while closely looking at footsteps while the blend happens, The footsteps appear a bit off and different than original flow. They appear to be out of synchronization for a moment. stepstart.footstepissue.mp43-While we start with run(By pressing shift+W) instead of first walking and then shifting to run, There appears an instant jerk at the start. starting.with.run.mp44-At low fps of around 25-40, The avatar slows down while running. Sometimes it doesn't run at low fps. run.slow.speed.mp4runatlowfps.mp4 |
avatars/avatars.js
Outdated
@@ -1635,6 +1643,9 @@ class Avatar { | |||
const currentSpeed = localVector.set(this.velocity.x, 0, this.velocity.z).length(); | |||
const angle = this.getAngle(); | |||
const timeSeconds = now/1000; | |||
|
|||
this.speedValue = lerpFloat(this.speedValue,currentSpeed,0.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks dependent on the frame time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have use fimeDiff in this calculation
avatars/avatars.js
Outdated
|
||
//console.log(currentSpeed); | ||
// Blend: idle <-> walk | ||
if (currentSpeed <= 0.45) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way to do it. We can smoothly blend on a curve over the
instantaneous velocity, not an if statement plus a lerp to switch between walk/run modally.
I have resolve main issue with this code. It is not modal. It is smooth. Works as expected. Also I had to introduce float speedValue (it is lerping to speed value, it respects timeDiff) beacuse there is no gradual change in speed between walk and run. |
2021-12-08.23-57-06.mp4 |
1-Crouch run can be improved as The transition from standing to walk and vice versa seems a bit fast and jerky crouchrun.mp42-The footsteps at the start of walk/run transition seem a bit off and needs improvement. footstepatstartissue.mp4The purpose of this PR is somewhat fulfilled. The walk/run transition has improved, the above mentioned issues can be solved in later PR's. So I recommend merging the current improvement into master. |
This needs a rebase after merging #1856 |
Rebase is done |
Made some major timing fixes, blending should be smooth now. |
Issue related to this PR:
#1695
Steps for testing:
Walk around
Press Shift to start running
Switch from walk to run and vice versa should not be instant