Hi there,
I have a iTween, rotateTo function question.
Can I set the direction of the rotation somehow?
Hi there,
I have a iTween, rotateTo function question.
Can I set the direction of the rotation somehow?
Use Vector3.RotateTowards. See the Doc for more info
Thanks,
this says it will be rotated on an arc. With out having tested yet, I just want a single axis rotation.
This still good for that?
An arc is a single direction.
oh right. I suppose so.
Thanks!
Sorry but I am having trouble figuring out how to script this.
var currentRotation : Vector3 = activePlayer.transform.rotation;
var targetRotation : Vector3 = Vector3(0, 0, intRotation); //intRotation is a float.
activePlayer.transform.rotation = Vector3.RotateTowards(currentRotation, targetRotation, 1.0, 1.0);
line 1 and 2 error:
Assets/scripts/wpnRealmScript.js(451,71): BCE0022: Cannot convert âUnityEngine.Quaternionâ to âUnityEngine.Vector3â.
transform.rotation is a Quaternion not a Vector3. If you need to assign rotation as a Vector3 use transform.eulerAngles.
Thanks,
I am still trying to figure it out.
var currentRotation : Quaternion = activeBrain.transform.rotation;
var targetRotation : Quaternion = Vector3(0, 0, intRotation);
activeBrain.transform.rotation = Vector3.RotateTowards(currentRotation, targetRotation, 1.0, 1.0);
var currentRotation : Vector3 = activeBrain.transform.rotation;
var targetRotation : Vector3 = Vector3(0, 0, intRotation);
activeBrain.transform.eulerAngles = Vector3.RotateTowards(currentRotation, targetRotation, 1.0, 1.0);
neither work.
Hi, this works for me. As per Unity - Scripting API: Transform.eulerAngles I noted that: âOnly use this variable to read and set the angles to absolute values. Donât increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotate instead. Do not set one of the eulerAngles axis separately (eg. eulerAngles.x = 10; ) since this will lead to drift and undesired rotations. When setting them to a new value set them all at once as shown above. Unity will convert the angles to and from the rotation stored in Transform.rotation.â
(my gameObject global x ârotationâ starts at 0 and just bounces between 0 and 90)
iTween.RotateTo(this.gameObject,iTween.Hash(
"x", this.gameObject.transform.eulerAngles.x+90,
"time", 60,
"easetype", "easeInOutSine",
"looptype","pingpong"
));