I’m trying to make a die spin at random speeds when it is created to simulate a roll of a die (it will spawn, start spinning, and fall down to collide with a plane below). I have everything working…except I can’t get the die to spin. I don’t need help with generating the random numbers, so for simplicity I removed RNG from my code for the time being. Here is what I have:
using UnityEngine;
using System.Collections;
public class Spin : MonoBehaviour {
void Create()
{
transform.localRotation = Quaternion.Euler (150, 250, 200); //arbitrary values
}
// Update is called once per frame
void Update () {
}
}
This doesn’t work at all. The die spawns, falls, and collides with the plane below just fine. It just doesn’t spin.
instead of the Euler method, I also tried:
transform.Rotate (Vector3.up, speed * Time.deltaTime);
transform.Rotate (Vector3.right, speed * Time.deltaTime);
transform.Rotate (Vector3.forward, speed * Time.deltaTime);
which did not work either. What changes to the above code do I have to make to make it spin properly?