Basically I want this gameObejct to move towards this plant.
public float speed;
public GameObject plant;
void Update () {
Debug.Log (transform.forward);
if (plant != null) {
transform.LookAt (plant.transform);
} else {
transform.LookAt (transform.forward);
}
transform.localPosition += transform.forward * Time.deltaTime * speed;
}
void OnCollisionEnter(Collision col){
if (col.gameObject.tag != "Wall") {
transform.rotation = Quaternion.Euler (0, 0, Random.Range (0.1f, 359.9f));
if (plant != null) {
Destroy (plant);
plant = null;
}
} else {
transform.rotation = Quaternion.Euler (0, 0, 90);
}
}
It starts out by going to the plant, and once it hits it, it destroys the plant and it faces (0, 0, 0) and wont face or move anywhere else. If anyone has any idea of what happening and how to fix it please let me know because this is turning my hairs grey with frustration. Thanks!