I have a simple object (transform var turbine), and i want it to smoothly face local directions, as it’s a child of the “jet” transform.
Here is the piece of code (attached to its parent “jet”):
But it doesn’t work.
Can someone help?
Also, is -Vector3.up the inverse of its absolute? I mean, live Vector3.down?
There are 3 directions possible for the “turbine” transform that is child of the “jet” transform. The directions are relative to it’s parent. I want to set these directions. But nothing that i’ve tried work.
Yes, your tip actually helped a lot. I was able to write a piece of code that actually works:
function TurnRight () {
turbine.localRotation = Quaternion.Slerp(turbine.localRotation, Quaternion(0,0,0.7,-1), 0.1);
}
function TurnLeft () {
turbine.localRotation = Quaternion.Slerp(turbine.localRotation, Quaternion(0,0,0.7,1), 0.1);
}
function Center(){
turbine.localRotation = Quaternion.Slerp(turbine.localRotation, Quaternion(0,0,0,1), 0.1);
}
However, I don’t know if it’s “okay” to use it because it’s pretty confusing and Unity manual said that it isn’t a good thing to manipulate quaternions.
Yeah, constructing the quaternions manually like that probably isn’t what you want to do. For one thing, the first two quaternions there aren’t unit-length (although the end result will likely be unit-length, as Unity generally keeps quaternions normalized ‘under the hood’). Also, although sometimes constructing a quaternion manually can produce sort-of-intuitive results, keep in mind that the elements of a rotation quaternion are not angles. (You can however use Quaternion.Euler() to create a quaternion from a set of Euler angles.)