Hello, I´ve searched for days to solve this problem, but I can't find the right solution. This is the situation: I have a dice prefab with a mesh collider attached. The mesh collider component has a different mesh applied with lower poly count and the option convex is checked.
The rigidbody component options are:
- mass=1
- drag&angular drag=0
- use gravity=true
- is kinematic=false
- interpolate=none collision
- detection=discrete
This is the code where I apply force on rolling the dice:
// cycle through dice instances
foreach(GameObject dice in diceInstanceList){
// check if current dice is in dice stack, if not roll it
if(!stackHandler.Contains(dice)){
// reset position
dice.transform.position = diceSpawn.position;
// reset rotation
dice.transform.Rotate(rndRotation());
// setup physics
dice.rigidbody.isKinematic = false;
dice.rigidbody.useGravity = true;
dice.rigidbody.mass = GamePlaySettings.diceMass;
dice.rigidbody.drag = GamePlaySettings.diceDrag;
dice.rigidbody.angularDrag = GamePlaySettings.diceAngularDrag;
dice.rigidbody.velocity = Vector3.zero;
// show dice
dice.renderer.enabled = true;
// push dice towards the board
dice.rigidbody.AddForce(transform.forward * GamePlaySettings.DiceForce);
} // - is dice in stack?
} // - foreach dice
Everything works fine but there are some overlapping issues. I roll (rigidbody.AddForce) 6 dice at the same time and the dice are overlapping each other. Look at the picture: ![alt text][1]
How do I avoid these issues? What am I doing wrong?
Thanks for your help and time!
Best, Arne
[1]: /storage/temp/25241-dicecolliderissue.jpg
↧