I’m new to both Unity and A* Pathfinding Project. So I’m sorry if this is an overly simple problem to solve. I feel i’m approaching the solution incorrectly.
Within the code of AIDestinationSetter.cs there is a line:
public Transform target;
This doesn’t work correctly with the Player being a prefab. As you can’t link gameobjects in a scene with a prefab.
I’m wondering if that line of code can be changed so that it will get the transform of a gameobject within the scene that it already knows the name of. No longer having it be drag and dropped in.
I would then have the same gameobject in every scene I create so that the Player prefab can find it. Is this the correct approach?
I want to make my Player a prefab for ease of learning with other assets. When the player isn’t a prefab, and is just a gameobject in the scene the pathfinding works perfectly.
I tried also making the Target transform into a prefab as well which allowed me to link its location to the Player prefab. However on game load the player will walk to the target location but it can’t be moved with mouse click anymore and will only use originally set location.
Maybe there is a whole new approach to this that I haven’t thought of or came across.
Your help would be appreciated.
Thank you all.