[SOLVED] Ball rolling around a planet bounces off?
Hello everyone,
I am trying to accomplish the following:
I have a big sphere which serves as a planet. This shpere has in its surface several smaller spheres which act as simple balls being attracted to the planet.
Here is the code that generates the gravity of the balls to the planet:
void Start () {
//finds the planet game object
puzzle = GameObject.Find("Puzzle");
//adds force towars the center of the planet
GetComponent<Collider>().attachedRigidbody.AddForce((puzzle.transform.position -
transform.position).normalized * force);
}
This works fine and the small blue balls "fall" towards the planet. Problem is, as soon as they come into contact with the planet, they all fly off violently. Both the planet an the blue ballls have a physics material with bounciness set to 0, but this makes absolutely no difference.
Doing some research I tried to adjust the planet's rigidbody to kinematic collision, and this indeed solves the problem of bouncing. However I want the small balls to rotate and move when the planet is rotated because of the friction. Simply put, the player input rotates the planet and the balls are moved reacting to it.
However, as soon as I set the planet's rigidbody to Kinematic, it stops reacting in any kind of way with the smaller blue balls. Sure, it kills the bouncing problem, but it also stops any other kind of interaction.
Is there any way to tweak collisions/rigidbodies to solve this?
Image of the rigidbody settings, small balls(left) and planet (right):
EDIT: see my own answer bellow for my solution.
Answer by UnbreakableOne · Jun 11, 2018 at 05:56 PM
Rotate as in rotate around themselves? Maybe using torque?
I don't understand why you use rigidbodies, at least for movement. Why not a simple movement vector and translate towards it or set it as velocity of your rigidbodies.
Yep, add torque did the rotation problem for me. Thanks a bunch!
The reason I use rigidbodies is because I want to move the small balls with friction from rotating the planet, and this is the method I thought of.
Answering your question, using a simple translate was the first thing I tried but friction didn't seem to work if done that way.
Answer by Manumeq · Jun 13, 2018 at 07:25 AM
For anyone who finds this post with a similar bouncing problem, here is the solution:
Just set the bounce combine to "multiply" instead of "minimum" in your physics material properties. For a reason I still don't understand, it seems if the bounding is set to 0, minimum doesn't seem to work, and anything multiplied by 0 results in 0 bounciness, so that did the trick for me.
Your answer
Follow this Question
Related Questions
how to prevent a kinematic rigidbody from going through static colliders 0 Answers
Rigidbody is colliding terrain on isKinematic = false. call although meshes don't touch 0 Answers
Move rigidbody cube without it tumbling 2 Answers
Is there a way to limit animation on collision? 1 Answer
Why Does Bounciness Affects Rigidbody Velocity? (SOLVED) 0 Answers