|
The objects are Ridigbody2d and Staticbody2d. Both have Physic Material Bounce values set. Does Staticbody2d Bounce value affect how Rigidbody2d bounces ? Lets say Rigidbody bounce value is 0.5 and Staticbody2d bounce value is 0.3. |
Answered by
Ughuuu
Oct 22, 2025
Replies: 1 comment
|
Hi, good question. The colliders have set: collider.set_friction_combine_rule(CoefficientCombineRule::Min);
collider.set_restitution_combine_rule(CoefficientCombineRule::Sum);As per docs: https://rapier.rs/docs/user_guides/rust/collider_restitution/, and looking in code also of rapier: impl CoefficientCombineRule {
pub(crate) fn combine(
coeff1: Real,
coeff2: Real,
rule_value1: CoefficientCombineRule,
rule_value2: CoefficientCombineRule,
) -> Real {
let effective_rule = rule_value1.max(rule_value2);
match effective_rule {
CoefficientCombineRule::Average => (coeff1 + coeff2) / 2.0,
CoefficientCombineRule::Min => coeff1.min(coeff2).abs(),
CoefficientCombineRule::Multiply => coeff1 * coeff2,
CoefficientCombineRule::Max => coeff1.max(coeff2),
CoefficientCombineRule::Sum => (coeff1 + coeff2).clamp(0.0, 1.0),
}
}
}It will do the sum of them (eg. 0.3 + 0.5 = 0.8). Similarly, the Godot bounce property: https://docs.godotengine.org/en/stable/classes/class_physicsmaterial.html#class-physicsmaterial-property-bounce In comparison, godot code does: real_t combine_bounce(GodotBody2D *A, GodotBody2D *B) {
return CLAMP(A->get_bounce() + B->get_bounce(), 0, 1);
}So also does sum, and caps at 1 (same as rapier one). |
0 replies
Answer selected by
Ughuuu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, good question. The colliders have set:
As per docs: https://rapier.rs/docs/user_guides/rust/collider_restitution/, and looking in code also of rapier: