I am developing a game in which I have a ball I have to throw. It must be able to collide with other balls (I have 10 for my demo). Right now, after colliding, the ball that has been hit is continuously moving and not stopping.
My solution for this problem is to enable isKinematic
for some time and then disable it. I access all the balls with a tag with code like this:
GameObject[] marbles;
marbles = GameObject.FindGameObjectsWithTag ("Exit");
foreach (GameObject x in marbles) {
x.GetComponent<Rigidbody> ().isKinematic = true;
}
My problem is that this only partially enables the objects. It enables some of the objects and disables the rest of the GameObjects. What is the problem with this code?
My boss told me to put a script on all the balls and then stop the balls by the same method (isKinematic
is true for some time), but I think it will lower the fps of the game if I use too many instances of one script on each gameObject. Which approach is better?