Get angle of collision between wall and player (rigidbodies)

Hi,

Just wondering if someone could give me a hint with regards to angle of collision. I have a character moving through a 3D environment. The walls have collision and are static rigid bodies.

The player has collision and is a dynamic rigid body. The player character moves constantly in the direction it is pushed in, until it collides with a wall. I need to get it to “reflect” off the wall (think pong) when it collides.

When I get the collision event (using this.entity.collision.on(‘collisionstart’… ) - I can’t see how to calculate the angle I would need to move away from the wall.

Any ideas?

Cheers.

If the player is a dynamic rigid body, it should just ‘bounce’ off the wall anyway? eg https://developer.playcanvas.com/en/tutorials/creating-rigid-bodies-in-code/

Do you have a link to the project?
What is happening at the moment and what do you think should be happening?

To answer your question directly: From the contact point, you have the normal of the collision. You will need to reflect the velocity vector of the moving object(s) around that normal: http://www.3dkingdoms.com/weekly/weekly.php?a=2

Thank you very much for your reply.

Yes - your questions highlighted a rather obvious problem I had regarding the movement of the character (i.e. the velocity was constantly being applied, so a collision against a wall would look like it had stopped, when in effect it was just moving in a constant direction).

As for your direct response - that does in fact look like what I am looking for.

Cheers!