Unity AI character behaves differently when instantiated at runtime versus placed in editor

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?

sounds like a timing issue tbh. when you instantiate at runtime the animator might not be fully initialized yet. try adding a small delay or coroutine before setting applyRootMotion = false. also check if your navmesh agent is enabled properly on runtime spawn - sometimes it needs a frame to setup correctly.