A* Pathfinding and AI Destination Setter Using Prefab Transform Instead of Scene Instance

Hello everyone,

I am currently encountering an issue with A* Pathfinding Project and the AI Destination Setter component in Unity. My enemy AI is supposed to move towards an instance of a prefab named “END” in my scene. However, it seems like the AI Destination Setter is using the Transform of the Prefab itself rather than the instance in the scene.

Does anyone know why this is the case and how I can correct it?

Thank you in advance for your assistance!

Hi

You’ll need to set it to the in-game instance of the object. This is more of a general Unity question than a question about this package. The relevant code and concepts should be covered by many introductory tutorials to programming in Unity.

Thank you for your answer and sorry to have asked a stupid question, I am new, here is the solution that I found to my problem. if some have the same problem as me

    private void SetDestination()
    {
        GameObject endObject = GameObject.Find("END");
        if (endObject != null)
        {
            AIDestinationSetter destinationSetter = GetComponent<AIDestinationSetter>();
            if (destinationSetter != null)
            {
                destinationSetter.target = endObject.transform;
            }
            else
            {
                Debug.LogError("No AIDestinationSetter found on this enemy!");
            }
        }
        else
        {
            Debug.LogError("No END object found in the scene!");
        }
    }