(Unity)オブジェクトをランダムな角度で表示するとき
最近Unity学び始めました。
ランダムな角度で3Dオブジェクトを表示させると、たまにDebug.Logで出てる角度と3Dオブジェクトのインスペクターで表示されてる角度(回転)が間違って表示されます。
###ソースコード
System.Random rnd = new System.Random(); int randX = rnd.Next(-180, 180); int randY = rnd.Next(-180, 180); int randZ = rnd.Next(-180, 180); ObjAngles.x = randX; ObjAngles.y = randY; ObjAngles.z = randZ; Obj.transform.Rotate(ObjAngles); Debug.Log("x = " + ObjAngles.x); Debug.Log("y = " + ObjAngles.y); Debug.Log("z = " + ObjAngles.z);
Unity側のObjインスペクター
x: 77
y: 127
z: 38
コンソール側のDebug.Log
x = 103
y = -53
z = -142
回答1件
あなたの回答
tips
プレビュー