Unity Steer - Setting Quarry in Steer for Pursuit problem


At present I have instantiated enemies with very basic AI. They spawn, they run at the player. End of story.

I want to overhaul my enemies using Unity Steer so that they avoid buildings/obstacles and each other, but I've run into a problem.

As my enemies are instantiated from prefabs rather than already in the scene, I seem to be unable to set my 3rd Person Controller (The Player) as the Quarry when using Steer for Pursuit. If I place an enemy on the level I can do it, but not if it's a prefab.

I've tried also making my 3rd person controller a prefab and setting it to that but that didn't work either.

Any help would be much appreciated.

I'm going to guess that you're trying to assign a reference to an object in the scene to a field of a script associated with a prefab.

If so, this won't work. Think about it this way. Prefabs exist outside of any particular scene. If a reference associated with a prefab points to an object in a particular scene, where will that reference point when a different scene is loaded? The object it points to won't even exist at that point.

What you'll most likely need to do is assign the player reference when the AI agent is instantiated. There are several ways this can be done; one would be to assign the reference immediately after instantiation using the return value of Instantiate(), and another would be to search for the player by name or tag and grab a reference in the Awake() or Start() function of a script associated with the AI agent.