i am new to unity and I need some help finding the x and z of another game object I have this code:
public GameObject wantedLegPosition;
private float wantedX;
private float wantedZ;
and I want the selected game objects (wantedLegPosition) x and z coordinate, and I want that to be wantedX and wantedZ, if you can help, that would be nice, thanks!
im sorry but this isnt what im looking for, I wanted to get the location of another game object, that could be changed by it being a public object not move my object, that part I can do on my own.
It isn’t always the best idea for everything to access everything else all over the place. For instance, it is BAD for the player to reach into an enemy and reduce his health.
Instead there should be a function you call on the enemy to reduce his health. All the same rules apply for the above steps: the function must be public AND you need a reference to the class instance.
That way the enemy (and only the enemy) has code to reduce his health and simultaneously do anything else, such as kill him or make him reel from the impact, and all that code is centralized in one place.
This is the bare minimum of information to report:
what you want
what you tried
what you expected to happen
what actually happened, log output, variable values, and especially any errors you see
links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?