I am currently creating an RTS game and as you can imagine I have many villagers on the screen at once. When it is time to build something the player must click a villager and then click on a building plot. I need the build plot to check for which villager has been licked otherwise all would try and build items. And this check is on the villager ‘ClickToMove’ script.
Now to currently I have the following code to check for a villager with that specific script activated:
function Start ()
{
villagerClick = clickToMove.FindGameObjectWithTag("villager");
}
However I know this doesn’t work and with there being multiple villagers I cannot place one on the variable before game launch. So does any one have any ideas on how to fix this?