- Home /
Gameobject Rotation Calculation
I want some help in rotation of Gameobject calculation. My player moving across pipe tunnels at different rotation, that calculation become difficult to perform for me.
Here are example of these worst situation:
In above example, I just want to take left rotation then also two axis get modified, rather than single axis modification. If I just turn only one axis then rotation not get affected, it taking other rotation.
At present I was using this code for moving on path and its iTween that detecting my rotation.
iTween.MoveTo(gameObject, iTween.Hash("path", positionVectorPoints, "time", ((transform.position - positionVectorPoints[positionVectorPoints.Length - 1]).magnitude / (speed * 1.5)),
"easetype", iTween.EaseType.linear, "orienttopath", true, "oncomplete", "OnCompleteRotate"));
So how to calculate rotation when I want to take turn at specific direction?
I hope, I explained my problem clearly. Please give me some suggestion regarding this.
Why don't you simply use Transform.Rotate ? Apply it on your camera transform and set the angles you want. If you know your start and end position between which you want to rotate, you can calculate the intermediate angles quite easily.
By touching actual gameobject when I try to apply rotation then also its two axis get modified when I reach at target. If I just give single axis modification then it will result into wrong direction rotation.
So you make a mistake in how you use the rotation... Don't forget that by default the rotation is calculated in object local space, there is a parameter to calculate the rotation in world space (but you must set it explicitely). If you mix these 2 coordinate spaces, it will result in incoherent result as you explain.