- Home /
java scrip, dice throw at a random rotation and force?
ok I've looked at lots of different answers but due to lak of really no scripting skill can't get any thing to work. so i need help simulating the die being tossed accross my board to left with a random rotation and force so it lands different every time.
Answer by chris114 · Mar 05, 2013 at 08:36 PM
this is what found from searching but i don't understand how to make it do what i want any tips?
function OnCollisionEnter(other : Collision) {
rigidbody.AddTorque (Vector3.random * Random.Range(-10.0, 10.0));
rigidbody.AddForce(Random.insideUnitCircle * 1, ForceMode.Impulse);
}
What is it doing, and what do you want it to do? The AddForce() is a bit strange...probably as a start want to add force using the forward vector of whatever is "throwing" the dice.
its only moving and spinning the Die after it hits something. I am trying to make the script throw the Die with a random rotation so lands differently each time at a force i set so it goes across my board I made. and I don't have any thing throwing it the Die is just siting out of camera view.
Your answer
![](https://koobas.hobune.stream/wayback/20220613093745im_/https://answers.unity.com/themes/thub/images/avi.jpg)