- Home /
iTween and 2D Platforming Tutorial Merge: Rotation of player and camera needed
I'm to work on a 2.5D game, as my previous question states. I have my player moving moving a path using iTween, however, I can't seem to get the rotation of the player's mesh and the rotation of the camera to work quite right.
function OnGUI () { value = value + Input.GetAxis("Horizontal") * speed * Time.deltaTime; iTween.PutOnPath(gameObject,path,value);}
//You can cause the object to orient to its path by calculating a spot slightly ahead on the path for a look at target: transform.LookAt(iTween.PointOnPath(path,value+.05));
}
I am using the PlatformerController script that was from the 2D Platformer tutorial as my base. I modified it on line here to allow the spline movement to work (rather, I comment the second line out:
function FixedUpdate () {
// Make sure we are absolutely always in the 2D plane.
//transform.position.z = 0;
This part right here is currently allowing the player to rotate to the direction he is going:
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (movement.direction), Time.deltaTime * movement.rotationSmoothing);
I believe that the rotation code from the spline and the rotation line in the PlatformerController may be affecting each other. I need the rotation of the player rotate towards the next way point. Thanks!
Answer by pixelplacement · Oct 17, 2010 at 05:07 AM
Just put an example together on the support site for iTween that I hope helps out with this. If you parent the camera to the character in this example and offset it from its right shoulder you will be able to have a camera that follows around curves. Hope it helps: http://itween.pixelplacement.com/examples.php
I bought the example, but it says that the seller hasn't uploaded it yet... :(
Sorry about that. I uploaded it as soon as I saw that I forgot it. Did you get it?