Hello everyone. I want to know how do I fix the rotation on the y axis in my 2d game. When running the game and change the rotation on the y-axis does not know how to fix it. In figure 2 is as it is running. I want to make it follow the path as in image 2. Tried a few things but did not work. Can anyone help?
‘orienttopath’ has the forward (positive ‘z’ side) of an object aligned to the path. So one solution is to use an empty game object.
Create an empty game object
Make your sprite a child of the empty game object
Set the childs local position to (0,0,0) so the child is at the same position as the parent.
Rotate the child so that whatever side is the front (right side I think from your picture) is aligned with the forward vector of the empty game object.
iTween.MoveTo() is called using the empty game object
A second solution I’ll mention but not give in-depth details is not use iTween.MoveTo() instead use iTween.PutOnPath() and/or iTween.PointOnPath(). With these functions, you’ll have to write a very simple bit of code to move along the path, but you will also then have the ability to calculate your own rotation frame-by-frame. This solution may be necessary if the previous solution end up flipping the sprite.