-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ray casting from fixture doesn't work in my example #58
Comments
The same example works with box2d-core: https://8observer8.github.io/webgl10-js/simple-can-jump-with-ray-box2dcore-webgl-js/ I copied my |
Example using Pixi.js instead of pure WebGL 1.0 as above When the square intersects the ray, the word "detected" should be printed to the console, but this does not happen. Sandboxes:
world.Step(dt, 3, 2);
world.DebugDraw();
const point1 = new b2Vec2(150 / pixelsPerMeter, 170 / pixelsPerMeter);
const point2 = new b2Vec2(100 / pixelsPerMeter, 170 / pixelsPerMeter);
const input = {
p1: point1,
p2: point2,
maxFraction: 1
};
const output = {
normal: new b2Vec2(0, 0),
fraction: 1
};
const ok = boxFixture.RayCast(output, input);
if (ok) {
console.log("detected");
}
// Render the stage
renderer.render(stage);
debugDrawer.clear(); The same example works with box2d-core I thought maybe it was my mistake, but I replaced box2d-wasm with box2d-core and the example worked. So I think it's a bug. But maybe I did something wrong. Sandboxes:
It's exactly the same code: world.Step(dt, { velocityIterations: 3, positionIterations: 2 });
DrawShapes(debugDrawer, world);
const point1 = new b2Vec2(150 / pixelsPerMeter, 170 / pixelsPerMeter);
const point2 = new b2Vec2(100 / pixelsPerMeter, 170 / pixelsPerMeter);
const input = {
p1: point1,
p2: point2,
maxFraction: 1
};
const output = {
normal: new b2Vec2(0, 0),
fraction: 1
};
const ok = boxFixture.RayCast(output, input);
if (ok) {
console.log("detected");
}
// Render the stage
renderer.render(stage);
debugDrawer.clear(); |
This is an alternative way of using ray casting, It is Sandboxes:
GitHub: https://github.com/8Observer8/falling-box-world-ray-casting-contact-listener-box2dwasm-webgl-js Discussion: #64 |
This code doesn't work:
It prints
grounded = false
:Example in Sandboxes:
Run in browser
GitHub Repository with sandboxes and instruction for Rollup.
I made this gif-animation to show that point1 and point2 are correct in this example:
world.RayCast
works:but
fixtures[i].RayCast
doesn't work.The text was updated successfully, but these errors were encountered: