dimforge / dimforge/bevy_rapier

Collider `set_scale` does not work.

Open
#452 3 comments 0 reactions 0 assignees View on GitHub
D-Medium documentation P-Low S-not-started
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

Setting the scale of a collider does not actually change its collider. Printing `Collider::raw` does show the collider being scaled correctly, but it's as if the actual physics and the debug render use the unscaled collider. To be clear, I'm testing collisions with a kinematic rigidbody (the example doesn't show this).

Example:
```rust
use bevy::{prelude::*, render::camera::ScalingMode};
use bevy_rapier2d::prelude::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RapierPhysicsPlugin::::pixels_per_meter(350.0))
.add_plugins(RapierDebugRenderPlugin::default())
.add_systems(Startup, spawn_collider)
.run();
}

fn spawn_collider(mut commands: Commands) {
let collider = Collider::convex_hull(&[
Vec2::new(1.0, -1.0),
Vec2::new(0.0, 1.0),
Vec2::new(-1.0, -1.0),
])
.unwrap();

let mut scaled_collider = collider.clone();
scaled_collider.set_scale(Vec2::ONE * 350.0, /* num_subdivisions= */ 1);
commands
.spawn(SpatialBundle::default())
.insert(scaled_collider);

commands.spawn(Camera2dBundle {
projection: OrthographicProjection {
near: -1000.0,
far: 1000.0,
scaling_mode: ScalingMode::FixedVertical(700.0),
..Default::default()
},
..Default::default()
});
}
```

Expected behavior: The scaled collider covers most of the screen.
Actual behavior: The scaled collider is tiny.

Manually updating the vertices to be scaled by 350.0 results in the correct output, but that is much less convenient than just using `set_scale()`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.