- Home /
iTween movetopath
Hello People.
I am using iTween to make a path for my camera to follow.
All good, but there are times when I want to have a switch (mouseUp an object)
that will make the camera move to a new path (path b)...
Scripting reference says : MoveTo(GameObject target, Vector3 position, float time)
but I am putting this script on another object, not the Camera.
using UnityEngine;
using System.Collections;
public class iTweenMoveTo : MonoBehaviour {
public GameObject myPath;
void OnMouseUp (){
iTween.MoveTo(Camera, iTween.Hash("myPath", iTweenPath, "time", 1));
}
}
I'm just screwed up on the C#...Any one have a clue?
Thanks
~be
Answer by Bentoon · Oct 19, 2014 at 05:39 AM
Alright I figured it so it works,
I have a script on the MouseUp object to trigger a switch to new path:
using UnityEngine;
using System.Collections;
public class iTweenMouseUp : MonoBehaviour {
//public string myPath;
void OnMouseUp()
{
Camera.main.GetComponent<iTweenPathCamera>().Path_2();
//NOTE: I am hardcoding this script - how can I make it a variable that I can type in in the inspector
}
}
and here is the script on The Camera:
using UnityEngine;
using System.Collections;
public class iTweenPathCamera : MonoBehaviour {
//public string myPath;
public void Path_1()
{
iTween.MoveTo(gameObject, iTween.Hash ("path", iTweenPath.GetPath("New Path 1"), "time", 12, "easetype", iTween.EaseType.easeInOutSine));
}
public void Path_2()
{
iTween.MoveTo(gameObject, iTween.Hash ("path", iTweenPath.GetPath("New Path 2"), "time", 12, "easetype", iTween.EaseType.easeInOutSine));
}
}
BUT:
it's too late and I'm being a moron ... I've hardcoded it this script - how can I make it a variable that I can type in in the inspector of the MouseUp script and Pass it to the Camera script?
Thanks ~be