- Home /
How to make an unrealistic bounce?
Hy everyone, My problem is that I want to have an unrealistic bounce between a plane and a ball, and I dont know how to script that. The problem is after the ball with the plane collides, its rotation stops and bounces a little bit along the y axis also. Here is a gif to illustrate my problem:
I noticed that when the ball with a capsule-collider colides, the bounce is almost (except the bounce along the y-axis) what i want:
I´ve tried to several functions to fix my problem (Vector3.reflect, calculate the inverse of the rotation, freeze the y position) but nothing worked perfectly. Can somebody help me out?
Answer by OfficialBAMM · May 16, 2014 at 02:47 PM
It seems like you need to freeze the Y position on the transform. Because it bounces in the air and your GIF that you want doesn't.
I´ve tried freeze the y position already but the ball starts rotating several frames later, like in the first gif, and the rotation isnt reflected immediately (second gif).
Answer by Loius · May 16, 2014 at 04:06 PM
You'll need to show your code if you need help fixing it. As it is I can only guess.
When you hit a wall, you need to reflect your ball's velocity around the normal of the contact. If you hit it straight on, you'll bounce exactly backwards, there should be no upwards momentum.
How's your physics material? Is the ball pulling itself up the wall?
The ball moves with a constant speed also the script for the ball is:
function Update()
{
rigidbody.velocity = maxSpeed * (rigidbody.velocity.normalized);
}
That´s all. The materials: -ball: dynamic, static fricton=0.4, friction, bounce combine=average; -floor: dynamic, static fricton=0.4, friction combine=maximum, bounce combine=$$anonymous$$imum;
Your ball is hitting the wall and wiggling the tiniest bit, your code is saying "oh your velocity is in such-and-such a direction, you now go full speed UP!". that is why you're bouncing. you need to either prevent the bounce or set your velocity to something with a Y value that you're okay with. You might try lerping your velocity's y value between where it is and where it thinks it should be.
Answer by andrew9994 · May 16, 2014 at 05:23 PM
The ball moves with a constant speed also the script for the ball is:
function Update()
{
rigidbody.velocity = maxSpeed * (rigidbody.velocity.normalized);
}
That´s all. The materials: -ball: dynamic, static fricton=0.4, friction, bounce combine=average; -floor: dynamic, static fricton=0.4, friction combine=maximum, bounce combine=minimum;
Your answer
Follow this Question
Related Questions
Unrealistic bounce 2 Answers
Change bouncing angle with touching speed 1 Answer
How to make ball bounce off screen boundaries? 1 Answer
Ball bouncing up after rolling over a cliff when it should be rolling down? 0 Answers
intelligent throwing 0 Answers