I'm trying to make the character go to tree, wit a few seconds, go to the camp and then back to the tree ect. but its not working my code is:
using UnityEngine;
using System.Collections;
public class ForagerAi : MonoBehaviour {
public int Health = 6;
public Transform Tree;
public Transform Camp;
public int moveSpeed;
public int myAcorns;
private Transform myTransform;
// Use this for initialization
void Awake() {
myTransform = transform;
}
void Start () {
GameObject t = GameObject.FindGameObjectWithTag("ForagerTree");
Tree = t.transform;
GameObject c = GameObject.FindGameObjectWithTag("Camp");
Camp = c.transform;
myAcorns = 0;
}
// Update is called once per frame
void Update () {
if(myAcorns == 0) {
transform.position = Vector3.Lerp(myTransform.position, Tree.position, Time.deltaTime * moveSpeed);
}
if(myAcorns == 5) {
transform.position = Vector3.Lerp(myTransform.position, Camp.position, Time.deltaTime * moveSpeed);
}
if(Health == 0) {
Destroy(gameObject);
}
}
public void WhereAmI() {
if(myTransform.position == Tree.position) {
myAcorns = 5;
}
if(myTransform.position == Camp.position) {
myAcorns = 0;
}
}
}
How do I make the character wait? Thanks in advance.