How I fixed my enemy not moving on waypoints

I did everything in the video, and my enemy didn’t move.

I output the transform.position to the log, and I noticed the Z axis was set to 5, and I’m not sure how that happened.

Once I updated the Z axis on all of my waypoint prefabs to 0 it moved as expected.

Hopefully this will help anyone else who encounters this issue.

24 Likes

Happened the same thing with me. Had to debug.log each and every step and found out that my Z was -2 for the Path(0) and the first waypoint was -2 . I wish I had seen your comment before i spent almost half an hour down the rabbit hole.

1 Like

i was stuck for 2 hours on this problem until i read this and never have felt more stupid.
That’s why he always says to reset when creating a new game object.

@Muneeb_Saeed, don’t feel stupid. I did reset my transforms, but somehow I still messed them up, and I couldn’t tell you how I did it.

If anything it’s a learning mistake, and I doubt you’ll make it again :wink:

Thanks a lot for the heads up. My enemy also didnt move after I followed all the steps, and it was driving me crazy. My Path’s Z-Axis was also not 0 and after I set it to 0 it started to move.

Just in case anyone has this same issue and their Z axis is just fine, make sure you moved all the waypoints AND enemy prefab onto the enemy waypoint section of the script. For some reason mine wasn’t attached, so the enemy only moved to the first waypoint and stopped.

1 Like

I have changed the Vector2 to Vector3 and worked just brilliant!

4 Likes

can u please explain what you mean by move the waypoints and enemy prefab?

Chris Semenov’s solution fixed my ship. It started to move again. Yey

:smiley: :

dude i love u and ur amazing

1 Like

I am happy to help!

Thank you! With this now I know why Rick always suggests to reset the game objects…

Omg thank you for this lmao, this whole time my paths weren’t working and the ship was spawning slightly in the wrong place then deleting and every one of my waypoints in the foreach loop had different positions than the waypoints in the path prefab. All I had to do to fix this was reset the path

This problem had me stumped for a good hour.

I initially tried to do the challenge by myself using the docs and got pretty close. I managed to get it appear at the first waypoint, then move to the second. But it would not move to the third, or update the index count. I tried a few different ways to go about it, but I kept getting the same issue or the enemy would not move at all.

I eventually just followed the video lecture and did exactly what he did. It still did not work. First time that happened, I thought unity or visual studio was broken.

Thank you, Thank you, Thank you for figuring out the z-axis hang up. I would have been stuck forever lol.

Oh my God. I am happy I have found this solution. It is soo stupid mistake. As Rick is always saying reset the position! :smiley: Thanks man!

Thanks a lot! I though I should not worry about the enemy prefab, since Rick posted that disclaimer over the Unity version issue, but it turns out Unity was missing the information on the enemy prefab, after all.

Any update on it?
I checked and my all Z - axis are at 0 but still my enemy do not move.
A little debugging and the problem seems to be that waypointIndex is not incrementing for some reason
I have even tried Copy pasting Code from the video and it still does not work ?
Update : changing “Vector2.MoveTowards” to “Vector3.MoveTowards” finally works, however still no idea why Vector2 isn’t working

I’ve tried everything but I still cant get it to work. These are my errors

Onto the enemy waypoint section of which script? Could you send a screenshot? These errors are making me go crazy

Privacy & Terms