Hi all. So I have controllable character and tree, and I would like the character to collide with the tree. But when I add colliders, the two objects won't collide but they overlap. Even with RapierDebugRenderPlugin turned on the collider boxes overlap. I tried adding different types of RigidBody to both objects, and only when one of the objects is RigidBody::Dynamic, then collision happens. But I don't want my objects to be RigidBody::Dynamic. Does anyone have idea what is happening? Here is my code:
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let texture = asset_server.load("punk.png");
commands
.spawn((
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100.0, 100.0)),
..default()
},
texture,
transform: Transform::from_xyz(100.0, 100.0, 0.0),
..default()
},
Player,
))
.insert(Collider::cuboid(50.0, 50.0));
}
fn spawn_tree(mut commands: Commands, asset_server: Res<AssetServer>) {
let texture = asset_server.load("tree.png");
commands
.spawn(SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100.0, 100.0)),
..default()
},
texture,
..default()
})
.insert(RigidBody::Fixed)
.insert(Collider::cuboid(50.0, 50.0));
}