- Home /
using iTween.ValueTo for the rotation of a GameObject with RotateAround
hi there!
is there a way to use iTween.ValueTo for the rotation of a GameObject with RotateAround?
with
iTween.ValueTo(thePlayfield, iTween.Hash("from", 0, "to", 1f, "onupdate", "rotateAroundToValue", "time", 1));
and the method on the GO
void rotateAroundToValue(float theValue)
{
Debug.Log(theValue);
gameObject.transform.RotateAround(theRotationPoint, Vector3.forward, theValue*180f);
}
it is not working. it is rotating like a newspaper in an old black&white movie... i want to rotate the GO 180
thnx!
Answer by Sarus · Mar 21, 2012 at 12:01 PM
transform.RotateAround will rotate your object by the provided number of degrees.
You've got the right idea.
With your current code the rotationValue is going from 0 to 1 every second which becomes a rotation of 0 to 180 degrees in the span of 1 second. This is what is causing your old black&white film effect.
Try this instead:
iTween.ValueTo(thePlayfield, iTween.Hash("from", 0, "to", 180f, "onupdate", "rotateAroundToValue", "time", 60));
void rotateAroundToValue(float theValue)
{
Debug.Log(theValue);
gameObject.transform.RotateAround(theRotationPoint, Vector3.forward, theValue);
}
This should rotate your object 180 degrees over the course of 60 seconds. You can speed it up by modifying the "time" value in the iTween.valueTo call. For example, if you want your object to rotate 180 degrees in 2 seconds just change the value to 2.
Hope that helps.
Your answer
Follow this Question
Related Questions
iTween ValueTo onUpdateParams passing 1 Answer
Is there an iTween rotate around ? 1 Answer
Using iTween ValueTo with onupdateparams 1 Answer
iTween ValueTo not working 1 Answer