Enemy teleports off of waypoint before "following" it's path

So I am pretty sure I am having the exact same issue as this one


but I just can’t seem to figure out why or how to fix it. I am pretty sure it’s unrelated to any of the scripts, as I have basically copied word for word the scripts shown in the course so far… but the Enemy seems to teleport to exactly 0,0,0 and then moving the designated path what looks to be right below on the Y axis but up 1 on the z axis. I am trying to get a video up for it but neither giphy nor Imgur are working for me.

When I play with the Inspector showing, it moves the enemy to 0,0,0 but My cubes already show their position as 0,0,0. Which makes this even more confusing to me because the enemy is below my scaled up cubes. so shouldn’t the enemy position be 0,-1,1?

  • Edit
    I put my cube position values in the text block really sloppily. so the waypoints show the cubes at

(0,0,0) (10,0,0) (20,0,0) (30,0,0) (30,0,10) (30,0,20)

The Enemy position is values are showing those exact same numbers BUT after hitting play, the enemy is position looks like it should be showing (even though it is not showing this)

(0,-10,10) (10,-10,-10) (20,-10,10) (30,-10,10) (30,-10,20) (30,-10,30)

I hope this edit helps.

Hi Reneda,

Could you please share more information on your project, on what you did, tried and see? Screenshots might be helpful. Are there any error messages in your console? Remember you can also look at the lecture code changes via the link in the Resources of each lecture.

No Error messages in my console, Here are the screenshots I took of editor mode vs play mode including the position coordinates of my enemy as well as my initial cube as well as final cube waypoints.

I have tried resetting the position of the cube as well as the enemy. I checked the code and my code seems to be accurate to the video. I removed and re-added the components to my cube prefabs as well as my enemy prefabs. I decided to clear my Hierarchy of cubes and enemy, rebuilt the path like we did in the video, and the issue persists.


after clearing everything and resetting the position then rescaling my prefabs, after dropping my enemy as well as my cube into the world (by dragging and dropping into my Hierarchy) this is exactly where they spawn.

both are showing position as (0,0,0)

I just redid the project(minus the code), I have no idea why it’s working this time, but it is working fine now. I am assuming it has something to do with setting up a parent for the body differently? Maybe I forgot to reset the position of both the empty game object (Empty) OR the Capsule (Body)? I went back to the original version and reset both of those and then re-scaled the Capsule back up. Works fine now.

Good job on solving the problem. :slight_smile:

That’s very likely the case. If the enemy (parent) is at the correct position but the mesh (child) is inside or next to the cube, the child has got an offset. If the child is at (0, 0, 0), it shares the same position with its parent. In that case, you would move the child and create an offset on purpose to get the desired visual result.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms