Hi, I want to return the Vector3 of a game object (target), then put that into a Method that will allow an AI(Agent) to subtract 1 over and over again from the value of another game object (Chest), once it reaches the coordinates of the game object (target) (note that “target” is next to “Chest”). I have been looking for an answer, and alo have been trying multiple different ways to get it to work but I can’t seem to find a way. Also I am not new to coding, but not an Expert either , I am intermediate with JS but want to use C# which I am not so familiar with.
Not entirely sure what your asking from your question, are u requesting both a way of moving your enemy toward the chest and also subtracting a value when this object is reached by your enemy? You can use Vector3.Distance to determine a float(number) value variable
then you could use an if to see if this distance is greater then
or less then the max distance u desire.
as for a method of moving the enemy toward the chest i recommend you watch BergZerg’s youtube tutorial on enemy AI it is quite short and very informative heres a link to the first of his enemy ai tutorials 3. Unity3d Tutorial - Enemy AI 1/2 - YouTube in these videos you will learn to check distance and direction of an enemy aswell as moving him based off these values. his section on Enemy Attack should be applicable to how u would like to remove a value from the chest
its all written in c# so you should be able to learn quite a bit, if you have any problems or need more information send me an email Skylem@live.com.au