I have an empty gameobject which is in front of the player (so wherever he moves, the gameobject is dead ahead).

There are tumbling cubes falling downwards from the sky, towards the player.

These cubes are spinning at random speeds on the x, y, and z rotation.

When they are caught by the empty gameobject (let’s call it “catcher”), I need to set the falling cube that gets caught rotation to 0.

So, in JavaScript/UnityScript I thought it would simply be:

Caughtcube.transform.Rotation.x = 0;

… And the same for the y and z axis.

Thing is, this always gives different results depending on the rotation of the falling cube, because the falling cube’s rotation is random.

I thought setting these values to 0 would work. It does in the inspector, but I need it done at runtime dynamically in script.

Any help greatly appreciated.

Rotations are handled in game as what’s called a Quaternion. Quaternions have 4 elements (x, y, z, w), however they do not correspond to the 3-axis rotation shown in the inspector (called Euler). Quaternions are used because they avoid gimbol lock, which is where an object gets stuck on one axis, however they are not easily understood by humans. Luckly there are some methods to convert between Quaternions and Euler.

To set an object to a specific 3-axis rotation, use `rotation = Quaternion.Euler(x, y, z)`

. Or to easily set to no rotation as you want, there’s `rotation = Quaterion.identity`

. Quaternion.identitiy is a constant for no rotation (equivalent to `Quaternion.Euler(Vector3.zero)`

)

Thank you @OncaLupe

This worked really well.

It turned out I had to use:

```
tclone.transform.rotation = Quaternion.Euler(0, 0, 0);
tclone.transform.localRotation = Quaternion.Euler(0, 0, 0);
```

and this achieved the effect I was after. Many thanks.