I have my player at a start point on the platform as pictured below… but when ever i run it, he is placed off the platform. Kind of wierd cause i dont have anything stating for it to offset its transform… Code of my click to move script as well…
Script Below:
public class ClickToMove : MonoBehaviour {
public float _baseSpeed;
private bool isWalking;
Animator playerAnim;
Animator liftAnim;
public GameObject lift;
NavMeshAgent agent;
void Start ()
{
playerAnim = GetComponent<Animator> ();
liftAnim = lift.GetComponent<Animator> ();
agent = GetComponent<NavMeshAgent> ();
//playerAnim.SetBool ("walking", true);
}
void Update ()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast (ray, out hitInfo)) {
GetComponent<NavMeshAgent> ().SetDestination (hitInfo.point);
}
}
if(Vector3.Distance(agent.destination, agent.transform.position)<=agent.stoppingDistance){
if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f) {
playerAnim.SetBool ("walking", false);
} else if (Vector3.Distance (agent.destination, agent.transform.position) > agent.stoppingDistance) {
playerAnim.SetBool ("walking", true);
}
}
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "buttonTop") {
Debug.Log ("Hitting Button");
liftAnim.SetBool ("down", true);
}
}
}