Skip to content

Commit dd0a0c8

Browse files
box2d: Correct mixup of the x and y coordinates (#2391)
The relative space type of the set position block in Box2D was set incorrectly such that it set the y position relative to the current x position rather than the y position. This means that setting inputs of -2, 20 would result in the sprite going negative in both directions, with the y coordinate always being +20 > the x coordinate. (see below video) ------------------------------------------------------------------------------------------------------ The following video shows the incorrect behavior (current) and the corrected behavior (this patch) using the same script: <img width="349" height="347" alt="Screenshot 2026-01-19 191552" src="https://github.com/user-attachments/assets/f83b7674-7d5c-485f-96e1-9bd1bd244d5f" /> https://github.com/user-attachments/assets/fe0ba0cd-c4cf-4379-8e03-de75ef6a31f1 ------------------------------------------------------------------------------------------------------ Didn't look before making this change but I'm pretty sure this patch resolves this issue: Fixes #935 Also, I think this bug is almost 7 years old, since I found the original patch in Griffpatch's VM fork, and it's from February 2019.
1 parent 91cad00 commit dd0a0c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extensions/box2d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13720,7 +13720,7 @@
1372013720
}
1372113721
break;
1372213722
case SPACE_TYPE_OPTIONS.RELATIVE: {
13723-
_setXY(util.target, util.target.x + x, util.target.x + y);
13723+
_setXY(util.target, util.target.x + x, util.target.y + y);
1372413724
if (body) {
1372513725
const pos = body.GetPosition();
1372613726
const pos2 = new b2Vec2(pos.x + x / zoom, pos.y + y / zoom);

0 commit comments

Comments
 (0)