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
I'm just getting started with RapierJS and I'm not being able to extend the example to have multiple RigidBodies. Only the first seems to work, but I'm not sure why. I get no errors.
Rigid Bodies except the first get a handle which looks faulty.
The position starts out undefined for all bodies.
0 undefined
5e-324 undefined
1e-323 undefined
After one step, all positions converge to the first (x = 0.30000001192092896)
How I created the bodies: (adding colliders makes no difference).
The handles you are getting are correct. Handles are some complex integers manufactured on the WASM side for uniqueness. When printed out as a javascript number, they won’t make any sense. In general, you should just assume that they are opaque identifier for your rigid-body.
There is no position field in rigid-bodies. You need to call .translation().
You might be interested in looking at some scene initialization examples as well as the user-guide.
My bad! Indeed I was using .position instead of .translation(), which explains the undefined.
But that wasn't all. I made that mistake only when typing the example code above for this issue report. I had a different mistake in my actual code, and that was that I somehow I ended up with this:
So it's all my mistake, no bug to see here :)
But it got quite confusing that I had no errors in the log and all objects look converged to the same position. That's because const body = world.getRigidBody(handle); with a handle which isn't a handle does return a valid looking body (the first one, with handle 0). So my iteration on "all bodies" was just hitting the first one multiple times.
When I tried to inspect more, I typed slightly different code and saw that the other handles look like float denormals and thought the problem was on the Rapier side.
Would it be very hard to type check the function calls I used?
The examples code is really useful! I had found the examples running as a demo, but not the respective code.
I'd suggest linking to the code in the demo page. ☺️
Version:
"@dimforge/rapier2d": "0.11.2"
I'm just getting started with RapierJS and I'm not being able to extend the example to have multiple RigidBodies. Only the first seems to work, but I'm not sure why. I get no errors.
Rigid Bodies except the first get a handle which looks faulty.
The position starts out undefined for all bodies.
After one step, all positions converge to the first (
x = 0.30000001192092896
)How I created the bodies: (adding colliders makes no difference).
The text was updated successfully, but these errors were encountered: