Clear velocity on previous WS / AD axis when changed to a new value#5050
Merged
dmarcos merged 4 commits intoaframevr:masterfrom May 5, 2022
vulture-boy:wasd-new
Merged
Clear velocity on previous WS / AD axis when changed to a new value#5050dmarcos merged 4 commits intoaframevr:masterfrom vulture-boy:wasd-new
dmarcos merged 4 commits intoaframevr:masterfrom
vulture-boy:wasd-new
Conversation
This was referenced May 2, 2022
dmarcos
reviewed
May 3, 2022
src/components/wasd-controls.js
Outdated
| adAxis = data.adAxis; | ||
| wsAxis = data.wsAxis; | ||
|
|
||
| // If a control axis was changed, reset its old velocity |
Member
There was a problem hiding this comment.
This would be better handled in an update method by checking the oldData parameter:
if (oldData.adAxis !== this.data.adAxis) { velocity[oldData.adAxis] = 0; }
Member
|
Thanks so much for submitting. I suggested a slightly different approach. |
Contributor
Author
|
Makes sense! Didn't realize there was an 'oldData' that could be accessed haha. |
Contributor
Author
|
Your approach is implemented! ✔️ |
Member
|
Thanks. Just edited to reformat and reword comment. Congrats on your first contribution 🎖️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In 1.3.0, if the WS or AD axes is changed during runtime, the old velocity associated with the last axis 'sticks' to the entity, resulting in often unwanted, constant movement. This change clears that velocity when the WS or AD axes are adjusted to a new value.
The script now monitors if the WS or AD axis is dynamically changed (via previous value variable) and clears the velocity value associated with its previous axis when a change occurs during an update. The nature of this stop is not smoothed, however... leaving that resolution to the future.