You have a plane at position 0,0,0 with a scale 15,1,15 (for demonstration)
Now you have a parent object for the sake of simplicity lets call it parentObject this parent object has the following transform: 7,25,26 The parent DOES NOT have a mesh and is thereby an empty gameobject
The parent has a childgameobjectHere the issue starts the child has a transform position at 5,-25,30 however this objects transform.position is relative to the parent.
last take our agent i know set him to go to childObject.transform.position will he then move correctly to the object or will he, in fact, move to the position that is relative to the parent object?
I know this might seem a bit messy but the general question is if i tell an agent to go to a gameobject that is a child of another object using transform.position will he go to the place we would expect?
Based off of the explanation you gave, yes. It should go to it’s position regardless of how it is relative to the parent object. That being said, by moving the parent object, you will also move the child object. But the NavMeshAgent should just go to the global position.
I was just reading a post on here from a while back that talked about finding children based on the parent. According to @CapeGuyBen on the post, the Hierarchy structure is stored in the Transform component, not in the GameObject component. You should be able to find the transform component of a child object by writing some code like:
Make sure to set “YOUR_OBJECT_NAME” to the name of the child object that you wish to find. This will only search the child objects of the parent object that you have defined. Then just set the NavMeshAgent’s destination to the position of the child object by saying:
NavMeshAgent nav;
void MoveToDestination () //This function can be named whatever you want
{
nav.SetDestination(child.position);
}
This should work fine for you but let me know if you run into any issues with the code. There’s a ton of people on this forum that would be more than happy to help out/link you do another post that might help you.