Skip to content

Modifying the angle of reflection for colliding objects #295

Answered by Jondolf
dacbd asked this question in Q&A
Discussion options

You must be logged in to vote

I want to induce some randomness to help ensure the balls don't bounce at angles too repetitive. My two ideas for this are to just induce some random +/- 3 degrees to the angle of reflection. Or some +/- effect based on how far from the center of the player the ball impacted.

You can either modify the contact normal or apply an impulse after the collision, like you mentioned.

To modify the contact normal, you need to access the Collisions resource in the PostProcessCollisions schedule. In your case, it might look something like this:

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, PhysicsPlugins::default()))
        .add_systems(PostProcessCollisions, modify_reflection_…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dacbd
Comment options

Answer selected by dacbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality
2 participants