dimforge / dimforge/bevy_rapier
ExternalForce/Impulse not working as expected
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 282
- PR merge metrics
- No merged PRs in 30d
Description
Since updating to 0.26, `ExternalForce` and `ExternalImpulse` do not seem to work correctly for me.
I've tried the same code with 0.25 and it works fine there.
As far as I can tell, it has to do with the unit conversion between game and physics world but I'm pretty new here so I don't know for certain.
Oddly enough, gravity still works as expected.
The setup I tested with uses 100 pixels per meter and applies a force to a 100x100 cube.
In 0.25, an impulse of 100 resulted in a velocity of 100 (this seems reasonable, as it should always be game world units being written to impulses/read from velocity from what I understand).
In 0.26, an impulse of 1000000 resulted in a Velocity of 100.
Relevant code snippets:
Adding the plugin and ppm:
```rs
.add_plugins(RapierPhysicsPlugin::::pixels_per_meter(100.0))
```
Spawning the rigidbody:
```rs
commands
.spawn(RigidBody::Dynamic)
.insert(GravityScale(0.0))
.insert(Collider::round_cuboid(50.0, 50.0, 0.1))
.insert(Velocity::default())
.insert(ExternalImpulse {
impulse: Vec2 { x: 0.0, y: 100.0 },
..Default::default()
})
.insert(TransformBundle::from(Transform::from_xyz(0.0, 400.0, 0.0)));
```
Reading the velocity:
```rs
fn print_velocity(q: Query<(&Velocity)>) {
for q in q.iter() {
println!("V: {}", q.linvel);
}
}
```
If this is a mistake on my end, I would appreciate any help on understanding what I was doing wrong :)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.