Hi guys, currently working on a runner game which uses lanes rather than movement. I’ve been working with the iTween scripts and have come up with a way to switch the lanes, however I can’t get the player to stay on the new lane or move to it (not just appear). Any help is greatly appreciated.
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
//private float smoothing = 1.0f;
private Vector3 targetPosition;
public float runSpeed = 0;
public Transform[] path;
public Transform[] path2;
public Transform[] path3;
float percentsPerSecond = 0.02f; // %2 of the path moved per second
float currentPathPercent = 0.0f; //min 0, max 1
// Use this for initialization
void Start ()
{
}
void Update ()
{
currentPathPercent += percentsPerSecond * Time.deltaTime;
iTween.PutOnPath(gameObject, path, currentPathPercent);
transform.LookAt(iTween.PointOnPath(path,currentPathPercent+.05f));
if (Input.GetKey ("a"))
{
iTween.PutOnPath(gameObject, path3, currentPathPercent);
transform.LookAt(iTween.PointOnPath(path3,currentPathPercent+.05f));
}
if (Input.GetKey ("d"))
{
iTween.PutOnPath(gameObject, path2, currentPathPercent);
transform.LookAt(iTween.PointOnPath(path2,currentPathPercent+.05f));
}
}
void OnDrawGizmos(){
iTween.DrawPath(path);
iTween.DrawPath(path2);
iTween.DrawPath(path3);
}
}