Hello friends!
I’m working on a snooker type of game. Large balls weigh 2kg, and small ones weigh 1.2kg.
So the large ones will collide and slow down, and the small ones ping away from each other!
I added a ball that was 100kg, to prototype a neutral, immovable circular object- like a tree or a fence-post. I’d like for all balls to bounce off of it, so you could tactically use it to ricochet shots around.
Sadly, all that happens when I smash the big one is that it saps all of my momentum. If I make the new ball 1,000kg it actually sucks in colliding balls and jitters the game to death every time.
Here’s my code for calculating collision velocities:
Vector3 difference = enemyBall.transform.position - transform.position;
float distance = Vector3.Distance (enemyBall.transform.position, transform.position);
Vector3 normal = difference / distance;
Vector3 velocityDelta = enemyBall.GetComponent<ballScript> ().moveVector - moveVector;
float impactSpeed = Vector3.Dot (velocityDelta, normal);
float coefficient = 0.5f;
float impulseStrength = (1 + coefficient) * impactSpeed * Mathf.Sqrt (1 / Weight + 1 / enemyBall.GetComponent<ballScript> ().Weight);
Vector3 impulse = impulseStrength * normal;
moveVector += impulse / Weight;
enemyBall.GetComponent<ballScript> ().moveVector -= impulse / enemyBall.GetComponent<ballScript> ().Weight;
I am uneducated in this topic! This is all self-taught tutorial stuff.
How can I manipulate this to get a nice clean bounce-off from all my regular-weighted balls?
For more examples of what a good bounce looks like, check out my other videos!
Thank you for reading guys, have a wonderful day!