Hi all,
is it me, or SetLookRotation is not working at all?
Sadly, the user manual’s entrance is pathetic and utterly useless, and even replicating the examples i’ve found around does not help.
I have a primitive to which i’ve attached the following script:
using UnityEngine;
using System.Collections;
public class recycleme : MonoBehaviour {
void OnMouseDown() {
print("I'm tryin'");
transform.localRotation.SetLookRotation(new Vector3(1f,1f,1f),Vector3.up);
}
}
Well, you can click till your finger falls off, but setlookrotation is actually doing nothing. Needless to say, if I perform any kind of rotation on the object, it’ll do it as intended, at each mouse click.
Wtf is going on please? ( as a side note, I just installed unity 3.4.)
thanks
system
3
I had this problem as well. The solution is to change the rotation by assignment.
It appears that in C# Unity stores a reference to the rotation. It need to be replaced.
using UnityEngine;
using System.Collections;
public class recycleme : MonoBehaviour {
void OnMouseDown() {
print("I'm tryin'");
Quaternion rotation = new Quaternion();
rotation.SetLookRotation(new Vector3(1f,1f,1f),Vector3.up);
transform.localRotation = rotation;
}
}
DaveA
2
Are you sure it’s doing nothing, or rotating by 1 degree (and not adding one degree every tick)? Are you trying to increment rotation on each click?