Ball Bounce And Rotating Walls
Hi there,
I started a new project in Unity5, it's a game about a bouncing ball and the player have to use the left and right keys to rotate the walls (this picture would help)
Everything was fine, the ball bounces well, but when I rotate the walls and the ball hit it, it goes up or something but it doesn't bounce as i want it to.
Let me explain, when the ball hit the floor (or the wall) and I rotate the wall counter-clockwise I want the ball to bounce 90° (well not exactly 90°) off the surface no matter what direction is the wall
Hope I made you understand my situation and hopefully you're gonna help me here.
Are you using unity physics to move the ball or you're own math?
A very simple and easy way to get "boucing" is to make the velocity of the object the negative of itself (0 - currentVelocity). But this would only be viable if you are keeping track of the ball's velocity yourself.
If you are using unity physics, set the gravity check box to off, set the drag to 0 and then just give it an initial impulse and it should do exactly what you are trying to achieve.
sorry for the late reply. Thanks, you helped me achieve what I was looking for.
You can use Vector3.Reflect to find out which direction you want the ball to move in and either directly set the velocity or addforce in the direction you want the ball to move. Do you have physics materials applied to the colliders? If not try setting up a physics material for the ball and the walls and play around with the bounce settings, this may help you achieve a more realistic "bounce" effect.
sorry forgot the link to the scripting API http://docs.unity3d.com/ScriptReference/Vector3.Reflect.html http://docs.unity3d.com/ScriptReference/Rigidbody.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612045555im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why Does Bounciness Affects Rigidbody Velocity? (SOLVED) 0 Answers
How do I get an object to behave like a balloon? 0 Answers
Objects wont stop bouncing if they fall. 0 Answers
What's the best method for pinball-type bumper physics (3D)? 1 Answer
When putting up the friction it doesn't change anything. 0 Answers