I am making a companion in my game that is supposed to run towards any character with the tag “Enemies”. I am pretty new to unity and have searched google multiple times. Here is the code i have so far for making the variable:
var Target = GameObject.FindWithTag (“Enemies”);
The point of the part after the equal sign is to replace the “Transform” that used to be there, which limited the target to only one particular enemy. What I am trying to do is make the variable equal to a tag and everything in it If anyone can tell me what to do about this it would be greatly appreciated!
Im sorry, like i said, i am new. What exactly does this code do? Do I put it after a variable, or make it like a separate one?
– jakobdv@jakobdv - if you don't understand this line of code, then I suggest reading/watching some tutorials on programming first. Start with this official series: http://unity3d.com/learn/tutorials/modules/beginner/scripting This won't take long, but will help you a LOT.
– ArkaneXAlso, it's worth thinking through the game logic very carefully with just pen and paper before you write any code. How exactly do you want your companion to run towards "enemies" (plural)? Towards the middle of a group of enemies? Or to the single closest enemy? Or a random enemy? It helps to have these sorts of decisions fixed in your mind because you're going to have to be explicit about them when you come to write the code.
– tanoshimi