AILerp - must it derive from MonoBehaviour?

I’m writing a custom AILerp. It would be more convenient if it were just a plain-old-c# script called by a different MonoBehaviour. Is IAstarAI entirely sufficient for interfacing with pathfinding or is there some strong reason to stay with MonoBehaviour (VersionedMonoBehaviour)?


Even implementing IAstarAI is optional. Movement scripts are pretty much self contained and other scripts usually do not interact with it directly (the movement script interacts with them instead of the other way around).

There are some scripts that use the IAstarAI interface and do require the script to be a MonoBehaviour. The AIDestinationSetter script and the Patrol script does this. The RVOController also has some code to automatically use the radius and height from the IAstarAI implementation, but this is easy to work around as you can just set those properties manually instead.

1 Like

Great, I’ve merged AIDestinationSetter into it. Now about Seeker and Modifiers (e.g. Smooth Modifier). It would also be possible to de-MonoBehaviour’d these so long as, from some MonoBehaviour, I call their OnDrawGizmos and OnDestroy, correct?

Technically yes (Seeker -> Start End Modifier is in fact a modifier which is not a mono behaviour), but why do you need to do all this?

The rationale for the AILerp and AIDestinationSetter is strongest. It’s possible that I can wrongly access a destroyed transform if my AI System assigns two agents the same target. I need to guarantee that the AI re-evaluates itself and switches targets. Currently, it does so correctly when each agent has one target, but if two target the same target, then no matter how I set Script Execution Order it’ll be an issue. By having my agent’s script call AILerp-AIDestinationSetter-combo then I can guarantee that there’s never a dead target. Other less important reasons are: (a) a bunch of updates are expensive, so I’d prefer to eliminate those. (b) I need to serialize my agents to a large degree (not their pathfinding tho), and for serialization reasons it de-complexifies the fewer Unity objects are involved. © I dislike Unity types because they sometimes create esoteric issues.Not set on changing Seeker or Smooth - just wondering.