I’m running into an issue with my AI character setup in Unity. When I drag the AI prefab directly into the scene through the editor, everything works perfectly. The character moves properly and all animations play correctly.
However, when I try to instantiate the exact same prefab during gameplay using code, the AI starts acting weird. The character gets stuck in idle animation and won’t transition to walking. There’s also an issue with the ground detection in my movement script.
Specifically, I’m using Unity’s standard third person controller on my AI. The problem seems to be in the ground checking method where this line causes issues:
characterAnimator.applyRootMotion = false;
Instead of playing the walk animation, the character just slides across the ground to reach its target. It’s like the ground detection isn’t working when the prefab is spawned at runtime.
I can’t figure out why the same prefab behaves so differently depending on how it gets into the scene. Has anyone encountered this before? What could be causing this difference between editor placement and runtime instantiation?