Hello
I am using iTween to control the Camera on a path with Touch (or arrow Keys)
This script (below) works well and gives me a visual editor (yay)
But now I want to SWITCH to a New path and still control it with touch
it’s a PITA
So I guess the easiest thing is on an event (like a mouse Up) where I want to switch to a new path
is just switch to a New Camera with the same Camera follow Path script on it
Maybe? But it’s not working and I am perplexed
Here is My Main Camera follow Path Script:
using UnityEngine;
using System.Collections;
public class FlythroughCameraController1 : MonoBehaviour {
public Transform[] movePath;
public Transform[] lookPath;
public Transform lookTarget;
public float percentage;
//public Transform[] path;
public float speed = 0.1f;
private float redPosition = .16f;
private float bluePosition = .53f;
private float greenPosition = 1;
// private float purplePosition = 1.2;
void Start(){
}
void Update () {
if (Input.touchCount > 0) {
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved) {
percentage += touch.deltaPosition.x * speed / Screen.height;
percentage = Mathf.Clamp01(percentage);
// ROBERTBU iTween.PutOnPath(gameObject,path,percentage);
iTween.PutOnPath(gameObject,movePath,percentage);
iTween.PutOnPath(lookTarget,lookPath,percentage);
transform.LookAt(iTween.PointOnPath(lookPath,percentage));
//transform.LookAt(iTween.PointOnPath(path,percentage+.05f));
}
}
if(Input.GetKey(KeyCode.UpArrow))
{
percentage += speed * Time.deltaTime;
}
if(Input.GetKey(KeyCode.DownArrow))
{
percentage -= speed * Time.deltaTime;
}
percentage = Mathf.Clamp01(percentage);
iTween.PutOnPath(gameObject,movePath,percentage);
iTween.PutOnPath(lookTarget,lookPath,percentage);
transform.LookAt(iTween.PointOnPath(lookPath,percentage));
}
void OnDrawGizmos(){
iTween.DrawPath(movePath,Color.magenta);
iTween.DrawPath(lookPath,Color.cyan);
Gizmos.color=Color.black;
Gizmos.DrawLine(transform.position,lookTarget.position);
}
void SlideTo(float position){
iTween.Stop(gameObject);
iTween.ValueTo(gameObject,iTween.Hash("from",percentage,"to",position,"time",2,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlidePercentage"));
}
void SlidePercentage(float p){
percentage=p;
}
}
A mouse Up event happens to switch Cameras, but doesn’t seem to work
__
using UnityEngine;
using System.Collections;
public class MouseUp : MonoBehaviour {
public Camera oldCamera;
public Camera newCamera;
void OnMouseUp()
{
oldCamera.camera.active = false;
newCamera.camera.active = true;
}
}
Any help is greatly appreciated
Thanks
~be