I have some code to modify an object’s rotation transform in the update statement, but I’m not getting the results I expected …
This code snipped, run in Update(), works fine and rotates the object as expected:
Transform t = GetComponent<Transform> ();
Quaternion q = new Quaternion ();
q.SetLookRotation(lookat,new Vector3 (0, 1, 0));
t.rotation = q;
This code does NOT rotate the object. Why the heck not?
GetComponent<Transform> ().rotation.SetLookRotation(lookat,new Vector3 (0, 1, 0));
Note: lookat is a Vector3 variable setup earlier in the code: setup not relevant, I think, because I pass the same values to both versions of the code. (Debug.Log tests confirmed this)
I suspect I’m missing something simple and obvious here, but I’m still stumped.