Skip to content

Commit cf504ac

Browse files
committed
Body.setVelocity was cause the speed property to be set to NaN if you didn't provide a y argument.
1 parent bef0b16 commit cf504ac

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Notes:
3535
* The `Body.delta` values are now able to be read and acted upon during a Scene update, due to the new game step flow. This means you can now call `this.physics.collide` during a Scene `update` and it will work properly again. Fix #4370 (thanks @NokFrt)
3636
* `ArcadePhysics.furthest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
3737
* `ArcadePhysics.closest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
38+
* `Body.setVelocity` was cause the `speed` property to be set to `NaN` if you didn't provide a `y` argument.
3839

3940
### Facebook Instant Games Plugin
4041

src/physics/arcade/Body.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,11 +1054,6 @@ var Body = new Class({
10541054
{
10551055
this.world.updateMotion(this, delta);
10561056

1057-
// if (!this.sleeping && this.gameObject.name === 'vu1')
1058-
// {
1059-
// console.log(this.world._frame, 'UP Y', velocity.y, position.y, this.prev.y, this.blockers.length);
1060-
// }
1061-
10621057
if (this.collideWorldBounds && !this.worldBlocked.none)
10631058
{
10641059
this.checkWorldRebound();
@@ -1273,7 +1268,7 @@ var Body = new Class({
12731268
this.sleeping = true;
12741269

12751270
console.log(this.gameObject.name, 'put to sleep on frame', this.world._frame, 'force?', forceY, 'at', this.y);
1276-
1271+
12771272
this.velocity.set(0);
12781273
this.prevVelocity.set(0);
12791274
this.speed = 0;
@@ -2084,6 +2079,9 @@ var Body = new Class({
20842079
{
20852080
this.velocity.set(x, y);
20862081

2082+
x = this.velocity.x;
2083+
y = this.velocity.y;
2084+
20872085
this.speed = Math.sqrt(x * x + y * y);
20882086

20892087
return this;

0 commit comments

Comments
 (0)