This question falls in line with my last question: Unity 3D - create autonomous moving robot in house + first person camera movement
What I have
I have a 3D model of a house; a first-person camera with movement through the house; a robot that autonomously moves.
What I want
I want the autonomously moving robot to search the house for certain objects. I have placed 4 guns (same model) in the house.
This is the code I have now. This works for 1 gun; not multiple game objects:
using UnityEngine;
using System.Collections;
public class MoveTo : MonoBehaviour {
public Transform goal;
void Start () {
NavMeshAgent agent = GetComponent<NavMeshAgent>();
agent.destination = goal.position;
}
}
What I want - extra
If possible, I want it to communicate with the person navigating the "game" with the first-person camera. For example, if it finds a gun, I want it to say to the person "playing" the game: I found a gun. If it finds the next one: I found 2 guns; I found 3 guns; etc etc.
For that, I used the following code for the player:
using UnityEngine;
using System.Collections;
public class UGV : MonoBehaviour {
public Player player; //assign this variable in the inspector, or using another method
public void CallMethodBInPlayer(){
if(player != null){
player.MethodB();
}
}
public void MethodA(){
//do something (Robot)
}
}
And the same for the robot (but changed accordingly).
I will be honest with you that I have very little understanding of programming or Unity. I want you to know I've been looking for an answer for many hours but even though the idea might be too complicated for me just yet, I still hope you can (and want) to help me :)