Hello people
Super grateful Robertbu helped me get my iTween Path working with Touch on my iOs devices, but now what if it I am on running on desktop…?
I want to use my arrow keys (either Up & Down or Left & Right) since it is on an iTween path and is simply bi - directional…
Here is the code I put on the Camera:
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;
//gui styling
public Font font;
private GUIStyle style = new GUIStyle();
void Start(){
style.font=font;
}
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);
iTween.PutOnPath(gameObject,movePath,percentage);
iTween.PutOnPath(lookTarget,lookPath,percentage);
transform.LookAt(iTween.PointOnPath(lookPath,percentage));
//transform.LookAt(iTween.PointOnPath(path,percentage+.05f));
}
}
}
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;
}
}
I’m a but lost with how the touch phase is using percentage & how I might create an “else if” Left or Right Arrow keys…?
if(Input.GetKey(KeyCode.RightArrow))
{
something something
}
if(Input.GetKey(KeyCode.LeftArrow))
{
something something
}
Thanks for taking time to look,
~ be