- Home /
Balls bouncing off each other
Hi,
i´m trying to make 2 (or more) balls bounce off each other when they Collide. I want to do a game where you are on a Plattform and have to push the other Players over the edge. Last man Standing wins. Now i have the AI for, pathfinding and Stuff but I dont know how to get the Balls bouncing off from each other. I tried the bouncy material, didnt work. Adding forces onCollisionEnter isn´t really working too.
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Player")
{
forceDir = ((collision.gameObject.transform.position - rigidbody.transform.position).normalized);
collision.rigidbody.AddForce((forceDir*impactForce,ForceMode.Impulse);
}
}
This is my code for the Collision so far, i´ve changed it multiple times. Last try was to add the current velocity to the Force so that the faster Player hits stronger, but if impact Force is too low almost nothing happens, if its a little bit too high the player kicks the enemy outta space so I changed it back to only adding the impactForce.
I have no clue how to acchieve the best Result for what i want to do, so hopefully somebody of you can help me.
Your answer
Follow this Question
Related Questions
Force in Circular Motion 1 Answer
Bouncing Ball and Walls 1 Answer
Cant find options to change physic material to bouncy 2 Answers