Version: A* Pathfinding Project Pro 4.2.15
Overview: When using Mecanim Bridge to a character with RichAI script attached, the MecanimBridge.cs
file throws endless exceptions on line 109:
NullReferenceException: Object reference not set to an instance of an object. Pathfinding.Examples.MecanimBridge.OnAnimatorMOve(). ...
This is likely due to the following line of code:
var newRot = RotateTowards(desiredVelocityWithoutGrav, Time.deltaTime * (ai as AIPath).rotationSpeed);
Solution: Adding an if else statement to the casting operation, and attempting to cast ai as RichAI on failure appears to fix this problem. (This logic can likely be improved upon):
var aiObject = (ai as AIPath);
if (aiObject == null)
{
var richAIObject = (ai as RichAI);
rotationSpeed = richAIObject.rotationSpeed;
}
else
{
rotationSpeed = aiObject.rotationSpeed;
}
var newRot = RotateTowards(desiredVelocityWithoutGrav, Time.deltaTime * rotationSpeed);