get object position by name

Is that possible to get objects position by name?

I need to check angle between transform.position and next NOT touched CheckPoint, so AI would know which way it should turn to go furher…

You can use a naming convention that is a numbered sequence (array or something). Then, when you are looking for the next point, just increment the name by one e.g. nextPoint += 1;

Hope this helps!

Hmm I think you didnt understand. For Example

CheckPoint1 is (32,41,83) position in the world and I want Raycast to point it BY NAME…

Is the check point a solid game object? What about RaycastHit.collider? This would return the collider and you should be able to link that to the parent game object, not sure if I’m on the right track…

Just use GmaeObject.Find, it’s in the documentation. From that get the transform’s position. Pretty basic.

You can’t find a game object if you don’t know what it’s name is…

I must be missing something. I thought the name was known? Like “CheckPoint1”?

So you’d have something like:

Vector3 position = GameObject.Find(“CheckPoint1”).transform.position;

MdK, can you shed some light? I think we are misunderstanding the question…

FizixMan did what I meant, thanks to all of U