Set default restitution

This commit is contained in:
Matthew Deville 2026-09-15 16:20:05 +02:00
parent 7c21eab970
commit 6f7d1a5f49
3 changed files with 6 additions and 3 deletions

View file

@ -21,6 +21,9 @@ fn main() {
PhysicsPlugins::default(), PhysicsPlugins::default(),
)) ))
.insert_resource(Time::<Physics>::default().with_relative_speed(5.0)) .insert_resource(Time::<Physics>::default().with_relative_speed(5.0))
.insert_resource(DefaultRestitution(
Restitution::PERFECTLY_ELASTIC.with_combine_rule(CoefficientCombine::Max),
))
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems( .add_systems(
Update, Update,
@ -75,7 +78,7 @@ fn spawn_ball(
commands.spawn(( commands.spawn((
RigidBody::Dynamic, RigidBody::Dynamic,
Collider::circle(CIRCLE_RADIUS), Collider::circle(CIRCLE_RADIUS),
Restitution::PERFECTLY_ELASTIC.with_combine_rule(CoefficientCombine::Max), LinearVelocity(Vec2::new(time.elapsed_secs().sin(), time.elapsed_secs().cos()) * 100.0),
Mesh2d(meshes.add(Circle::new(CIRCLE_RADIUS))), Mesh2d(meshes.add(Circle::new(CIRCLE_RADIUS))),
MeshMaterial2d(materials.add(Color::hsl(time.elapsed_secs().sin() * 360.0, 1.0, 0.5))), MeshMaterial2d(materials.add(Color::hsl(time.elapsed_secs().sin() * 360.0, 1.0, 0.5))),
Transform::from_xyz(world_position.x, world_position.y, 0.0), Transform::from_xyz(world_position.x, world_position.y, 0.0),

View file

@ -5,7 +5,7 @@ PROFILE="${1:-release}"
if [ "$PROFILE" = "dev" ]; then if [ "$PROFILE" = "dev" ]; then
PROFILE_DIR="debug" PROFILE_DIR="debug"
CARGO_FLAGS="" CARGO_FLAGS="--features=bevy/dynamic_linking"
else else
PROFILE_DIR="release" PROFILE_DIR="release"
CARGO_FLAGS="--release" CARGO_FLAGS="--release"

View file

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "1.98.1" channel = "1.98.1"
targets = ["wasm32-unknown-unknown", "x86_64-unknown-linux-gnu"] targets = ["wasm32-unknown-unknown"]
components = ["clippy", "rust-analyzer", "rustfmt"] components = ["clippy", "rust-analyzer", "rustfmt"]