hello, how can i offset the game object from the path defined? here is my code!
using UnityEngine;
using System.Collections;
public class follow : MonoBehaviour {
public bool IsleftOn = false;
public bool IsRightOn = false;
private Vector3 targetPosition;
public float runSpeed = 0;
public Transform[] path0;
public Transform[] path1;
public Transform[] path2;
private Transform[][] paths = new Transform[3][];
private int iPath = 1;
float percentsPerSecond = 0.02f; // %2 of the path moved per second
float currentPathPercent = 0.0f; //min 0, max 1
void Start () {
paths[0] = path0;
paths[1] = path1;
paths[2] = path2;
}
void Update () {
IsleftOn = PlayMakerGlobals.Instance.Variables.GetFsmBool("leftcontrol").Value;
IsRightOn = PlayMakerGlobals.Instance.Variables.GetFsmBool("rightcontrol").Value;
runSpeed = PlayMakerGlobals.Instance.Variables.GetFsmFloat("playerspeed").Value;
if (IsleftOn == true) {
if (iPath == 2) iPath = 1; else iPath = 0;
PlayMakerGlobals.Instance.Variables.GetFsmBool("leftcontrol").Value = false;
}
else if (IsRightOn == true) {
if (iPath == 0) iPath = 1; else iPath = 2;
PlayMakerGlobals.Instance.Variables.GetFsmBool("rightcontrol").Value = false;
}
currentPathPercent += percentsPerSecond * runSpeed;
iTween.PutOnPath(gameObject, paths[iPath], currentPathPercent);
transform.LookAt(iTween.PointOnPath(paths[iPath],currentPathPercent+.01f));
}
void OnDrawGizmos(){
iTween.DrawPath(path0);
iTween.DrawPath(path1);
iTween.DrawPath(path2);
}
}