#pragma strict
private var agent : NavMeshAgent;
var tno : TNObject;
function Start () {
agent = GetComponent.<NavMeshAgent>();
tno = GetComponent.<TNObject>();
}
function Update () {
if (tno.isMine) {
var hit: RaycastHit;
if (Input.GetMouseButtonDown(0)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, hit)) {
tno.Send("SetTarget", TNet.Target.All, hit.point);
}
}
}
}
function OnNetworkPlayerJoin() {
tno.Send("SetTargetImmediate", TNManager.player, transform.position);
}
@TNet.RFC
function SetTarget (tar) {
agent.SetDestination(tar);
}
@TNet.RFC
function SetTargetImmediate (pos : Vector3) {
transform.position = pos;
}