- Home /
Quaternion Slerp - Rotate to Angle?
Okay, here's the code from the reference manual:
// Interpolates rotation between the rotations
// of from and to.
// (Choose from and to not to be the same as
// the object you attach this script to)
var from : Transform;
var to : Transform;
var speed = 0.1;
function Update () {
transform.rotation =
Quaternion.Slerp (from.rotation, to.rotation, Time.time * speed);
}
My question is, can I use Quaternion.Slerp to rotate to angles given in floats, rather than rotating towards external objects?
Cheers!
Answer by DaveA · Jun 13, 2011 at 10:00 PM
Yes by itself is too short an answer
To just add a little something to the single yes, just change your var "to" in a function where you control where and when. As long as it's a fixed position this is a good solution, otherwise an array of objects would be suitable perhaps. Tip: Empty static gameobjects doesn't require much from the engine and is easier to work with rather than abstract values.
Ah, okay, I wondered about if game objects were a CPU drain or not... I might just have a few empty ones as targets. Thanks!
Your answer
Follow this Question
Related Questions
Rotate on one axis and check if angle is inside desired range 2 Answers
Set rotation based on 1,1,1 style vector? How to convert vector3 to quaternion? 1 Answer
How to Find an Object close to where the Player is Looking 1 Answer
Gameobject Rotation Calculation 0 Answers
Interpolate rotation of character. 0 Answers