Search code examples
unity-game-engineinstantiationa-starprefab

A* (Astar) Pathfinding doesn't work with Player Clone / Instantiate Unity


My player spawns at game play.

when i put my Player Prefab into "target" then it doesn't follow. but when i put my clone(instance) of my prefab (what spawned in the hierachy when i start the game) into "target" then it works.

how can i do that the target get automatically the instance of my player prefab? i was thinking about anything with "find game object with tag" but i'm legit a c# noob, i prefer using bolt. only for the pathfinding i need to use that way.


Solution

  • One option is to use the function GameObject.Find. E.g. GameObject.Find("Player"); or GameObject.Find("Player(clone)");. This will find the GameObject with that name. Here is the documentation for it: https://docs.unity3d.com/ScriptReference/GameObject.Find.html