kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

fix: add return if static to physics apply force functions

Open dragoncoder047 opened this issue 1 year ago • 1 comments

I noticed by accident that if a static body collides with an area effector, then the velocity of the static body will still be modified and the static body will fly off into the ether. But it's static, it shouldn't move. This fixes that.

kaplay();

add([
    pos(10, 10),
    rect(100, 100),
    color(BLUE),
    area(),
    areaEffector({ forceAngle: 0, forceMagnitude: 10 }),
]);

// Wheeeeeee!! I am static but still get pushed!
add([
    pos(20, 20),
    rect(100, 10),
    color(RED),
    area(),
    body({ isStatic: true }),
]);

dragoncoder047 avatar Oct 09 '24 21:10 dragoncoder047

Open in Stackblitz

npm i https://pkg.pr.new/kaplayjs/kaplay@443

commit: 93b3c44

pkg-pr-new[bot] avatar Oct 09 '24 21:10 pkg-pr-new[bot]

wait sorry nvm to that i reread what you wrote

niceEli avatar Oct 30 '24 16:10 niceEli

This is both versions? We could say it was a bug?

lajbel avatar Nov 28 '24 01:11 lajbel