Okay, I got one

Hey! So I just finished up this lecture and everything looks great, BUT when hitting play my enemy moves to the first waypoint in my new path and then does not move from there. Seems like no one else had this problem, so I know it must be a me error. I am also using Unity 2019.2.17f1, so does that change what is going on here?

1 Like

Hi Drew,

Actually, this is a quite common problem. There should be a couple of threads in the Q&A section, and probably also here.

Make sure that the z-position of your enemy matches the z-position of your waypoints. Otherwise, the if-condition which increases the waypointIndex by 1 will never get evaluated to true.

Hey! So I have spent the last while looking over everything and I still cant seem to figure out the issue. The only thing I can think of is Rick mentioning the newer Unity updates have nested prefabs. Would that mess up this operation? I checked and all my Z axis are right, as well (But i did check after you’d mentioned it because I thought"well that makes sense")
my enemy was moving along the path fine until I implemented the Wave Configuration scriptable opject. and you cannot just drag and drop the prefabs into the configs anymore.

No errors or warnings show up when i play the build so far either. The enemy sprite just appears at the first waypoint and does not progress or move to the rest of the way points on the path.

Thanks again for you time. I’m sure when its fixed I will look back and shake my head at this.

Probably not. If you instantiate a prefab, it’s not a prefab anymore but a normal game object in your scene.

Check the z-positions of your parent game objects in your Hierarchy too. The position of a child in the Inspector is always relative to its parent. If the parent is at (0, 0, .123), and the child appears to be at (1, 1, 0), it’s actually at (1, 1, 0.123).

If nothing helps, change Vector2 to Vector3 in your code where the enemy is moved towards a waypoint. This way, its z-position will also get changed via code.

Hey! I ended up changing the code to Vector3 for my problem fix. I did look over all of it and saw that there was a Z axis problem but everything was zeroed out. So I deleted the full path, made sure i reset transform upon remaking it and then changed the code to Vector3 to triple make sure it was working. So hey! WE DID IT! Thanks Nina. You’ve been a big help

1 Like

You’re welcome. :slight_smile:

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

Privacy & Terms