How can i force collision angle
Here is the thing 1/ a ball with a rigidbody 2/ A sphere 3/ in a 3D tunnel with a wall at the end, top, bottom, left and right 4/ a paddle
The paddle launch the ball forward, hit the wall and come back (z axis)
The sphere is in the middle of the tunnel.
When the ball is hitting the sphere using physics engine, sometimes (depending on the contact point) the bounce has angle that I want to limit because the bounce direction (reflected vector) doesn't match what i want. For example I don't want the ball to get an angle that goes up and down (or left and right) with very low angle ( ex 5 degree). But backward and forward is allowed (hitting the end wall or the sphere and coming back is allowed, even with a small angle) So I want to define series of boundaries for this angle and if the bounce angle is not in the boundary I force the angle to the nearest boundary. I've found lot of infos about vector reflection, vector angle.. but I don't know how the force the right vector reflected regarding an angle I want.
Thanks for your help
Answer by Statement · Oct 10, 2015 at 12:24 AM
I guess a first step would be to properly define desired outcomes for different scenarios. It's a bit tricky to think about. Perhaps you could as a first test do something really crude to get a sense for how it would work out, like, if the Z velocity is below a certain treshold, gradually increase velocity until it has enough speed to get out of the "boring Y ping pong zone". It would of course not be physically correct and would behave a little like a remote controlled unit but if you tweak the speed in which it adjust Z velocity you may get away with a simple solution.
Yeah @Statement,
thanks a lot, I didn't think it this way. I've just test to force z velocity to keep it in a certain range on collision exit event and it works well. So no need to handle complex solution with angle. Thanks a lot for your help.
Your answer
Follow this Question
Related Questions
Ball won't stop bouncing 1 Answer
Struggling with bounce pad in platformer game. 1 Answer
Limit bouncing to x and y axis only, not z axis. 0 Answers
Raycast not always detecting floor 1 Answer
How to let a object dodge a collision? 0 Answers