- Home /
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...
Answer by Noah-1 · Oct 23, 2012 at 12:15 AM
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!
Your answer
Follow this Question
Related Questions
GameObject facing fowards 1 Answer
Getting the face direction 2 Answers
Straighten out camera rotation 1 Answer
how to set rotation / position of an object on trigger? 2 Answers
find the angle to rotate the gun to face mouse point with its barrel 1 Answer