using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WoodmanAI : MonoBehaviour
{
public GameObject log1;
public GameObject log2;
public GameObject log3;
public GameObject log4;
public GameObject log5;
public GameObject Firechamber;
private UnityEngine.AI.NavMeshAgent navAgent;
public GameObject agentDestination;
public void OnTriggerEnter(Collider other)
{
//Once Player collides with this log they destroy the prefab
if (other.tag == "Log1")
{
other.gameObject.SetActive(false);
navAgent.destination = Firechamber.transform.position;
}
//Once Player collides with this log they destroy the prefab and return to the fire place
if (other.tag == "Log2")
{
other.gameObject.SetActive(false);
navAgent.destination = Firechamber.transform.position;
}
//Once Player collides with this log they destroy the prefab and return to the fire place
if (other.tag == "Log3")
{
other.gameObject.SetActive(false);
navAgent.destination = Firechamber.transform.position;
}
//Once Player collides with this log they destroy the prefab and return to the fire place
if (other.tag == "Log4")
{
other.gameObject.SetActive(false);
navAgent.destination = Firechamber.transform.position;
}
//Once Player collides with this log they destroy the prefab
if (other.tag == "Log5")
{
other.gameObject.SetActive(false);
navAgent.destination = Firechamber.transform.position;
}
//Return to fireplace after collecting log
if (other.tag == "Fireplace")
{
if (GameObject.Find("Log2") != null)
{
navAgent.destination = log2.transform.position;
other.gameObject.SetActive(false);
}
if (GameObject.Find("Log3") != null)
{
navAgent.destination = log3.transform.position;
other.gameObject.SetActive(false);
}
if (GameObject.Find("Log4") != null)
{
navAgent.destination = log4.transform.position;
other.gameObject.SetActive(false);
}
if (GameObject.Find("Log5") != null)
{
navAgent.destination = log5.transform.position;
other.gameObject.SetActive(false);
}
}
}
// Start is called before the first frame update
void Start()
{
navAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
if (agentDestination != null)
{
navAgent.destination = log1.transform.position;
}
}
}