All I did was make clicking on the terrain in the InputManager use SendMessage to send the lasthit recorded from the NGUI raycast to movePlayer() in the MovementManager by using UICamera.lastHit.point as the target position.
Input:
using UnityEngine;
using System.Collections;
public class InputManager : MonoBehaviour {
public GameObject terrain;
private void Awake()
{
UIEventListener.Get(terrain).onClick += terClick;
}
public void terClick(GameObject terrain)
{
gameObject.SendMessage("movePlayer");
}
}
Movement:
using UnityEngine;
using System.Collections;
public class MovementManager : MonoBehaviour {
public void movePlayer()
{
iTween.MoveTo(gameObject,iTween.Hash("position",UICamera.lastHit.point,"speed",4f,"orienttopath",true,"easetype","linear","looktime",2f,"axis", "y"));
}
}
↧