You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the maxSpeed property with a given body in arcade physics, the expected behaviour is that the speed of that body will be capped on each physics update step. In practice, it appears that this only applies on every other step. As a result, arcade bodies with a maxSpeed value will end up moving slightly faster than they should.
The cause of this behaviour appears to be in the 'computeVelocity' function. When deciding whether to scale the body's velocity, a comparison is made to confirm that speed > maxSpeed. At this point, speed has not actually been updated to represent the body's new velocity. As far as I can tell, changing this comparison to body.velocity.length() > maxSpeed should fix the undesired behaviour.
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue, and for submitting a PR to fix it. We have merged your PR into the master branch and attributed the work to you in the Change Log. If you need to tweak the code for whatever reason please submit a new PR.
Version
Description
When using the
maxSpeed
property with a given body in arcade physics, the expected behaviour is that the speed of that body will be capped on each physics update step. In practice, it appears that this only applies on every other step. As a result, arcade bodies with amaxSpeed
value will end up moving slightly faster than they should.Example Test Code
https://codesandbox.io/s/phaser-3-max-speed-issue-iu9beh
Additional Information
The cause of this behaviour appears to be in the 'computeVelocity' function. When deciding whether to scale the body's velocity, a comparison is made to confirm that
speed > maxSpeed
. At this point, speed has not actually been updated to represent the body's new velocity. As far as I can tell, changing this comparison tobody.velocity.length() > maxSpeed
should fix the undesired behaviour.The text was updated successfully, but these errors were encountered: