my enemy is walking on an invisible surface

i have an enemy setup with a capsule collider and nav mesh agent and follow script as described in the beginner unity tutorial for enemies :

my terrain is not flat, and it’s also not centered around the origin.

whenever i have the mesh turned on, my enemy does head towards the destination as he’s supposed to… but he seems to be walking on imaginary hills. it would look really cool if there was actually a hill there, but there’s not.

here’s a screenshot :

50143-unity.png

you can see enemy in upper right walking up the invisible hill, then walking back down on otherside. this is exactly what he would do if he was at the origin, but he’s not.

i assume he is walking along the mesh and the mesh is telling him to move that way. i don’t see why the mesh is setup this way, unless it’s assuming the original terrain origin.

i tried adjusting the mesh agent to have the same center as the terrain, but this had no effect.

i also tried to do the same adjustment on the mesh itself, but the mesh has no transform component. i tried switching the nav instantiation to occur after the terrain has it’s coordinate adjusted, but no effect. i also have rebuilt the nav mesh several times, including with and without height maps. again still same behavior.

it seems very simple and i can’t find any posts where anybody is having this problem, so it must be an easy fix.

can anybody tell me what i’m doing wrong?

Maybe your capsule collider is not close enough to your character’s mesh, there might be a gap which can be observed on the picture you posted.

unity upgrade that came out today also did not correct this.

ultimately i just ended up switching from transforming the terrains initial position, to transforming all the objects. this corrected the problem and now the enemy’s path now matches the physical terrain. i’ll attribute this to an unreported bug in the nav mesh (or at least undocumented “feature” that you should not transform the terrain after baking the mesh).

all working now.