- Home /
Random Rotation all 3 Axes
Hey outta there,
I'm quite new to Unity3d. I want some cubes, which are moving from top to bot to rotate. Them should be given at their spawn one random rotation and speed, in all 3 axes and they should rotate with the random speed every frame. I've looked up in unity3d forum so many posts, but couldnt find exactly that and were also unable to build it up myself.
i created them via GameObecjt in unity, sry dont know what a rigidbody is...
Answer by iagoccampos · Aug 13, 2014 at 01:03 AM
rigidbody.angularVelocity = Random.insideUnitSphere * tumble;
Answer by Owen-Reynolds · Nov 11, 2012 at 03:55 PM
Rotations are really Quaternions, which can be built from x,y,z rotations. Ex: `transform.rotation=Quaternion.Euler(0,45,0);`. For an initial random spin, just toss in random #'s:
float xSpin = Random.Range(0,360); ... same for y and z
transform.rotation=Quaternion.Euler(xSpin, .... );
For continuous rotation, at least three ways. Either `transform.Rotate(...);` or alternately move the original vars: `xSpin+=xSpinSpd;` and then reset using the original command.
Or, toss in a rigidbody, at start set `angularVelocity = new Vector3(smallRandom,...);`, drop the angular drag to 0, and let Unity automatically spin it for you.
Your answer
Follow this Question
Related Questions
Reseting rotation of a random turret 1 Answer
Random Turning? 1 Answer
Object Rotating Randomly 1 Answer
Space.World in MoveObject.js 2 Answers