How do I make sure a object faces a certain direction?

I’ve been try to rotate something but I don’t want it to rotate past a certain point, I just want to have the object rotated a set amount, say, facing north, but if the script is triggered again, it doesn’t rotate further, it still faces north. I only know how to rotate something continuously or repeatedly…

If you want to limit the rotation to a certain point, you can use Quaternion.eulerAngles
Basically you set the degrees you want your object to rotate:

//Rough example: rotate cube 30 degrees

var cube: Transform;
var rotation = Quaternion.identity;

function Update(){

cube.rotation.eulerAngles = Vector3(0,30,0);

}

Hope that helps you!