conf t

インフラエンジニアのメモ

Unityでtransform.rotationに値を代入する

Unityでtransform.rotationには直接値を代入できません。

値を代入したい時は、以下です。

float x = 90;
this.transform.rotation = Quaternion.Euler(0.0f, 0.0f, x);

回転させたい時は、以下です。

float x = 90;
this.transform.Rotate(0.0f, 0.0f, x);

参考:

answers.unity3d.com