My enemy wont move

i think this matches exactly what the instructor did. but mine doesn’t work.

if i move this:
if (transform.position == targetPosition)
{
waypointIndex++;
}
above my vector 2.movetowards, then it will move to waypoint 2. but it wont continue.
if i leave it this way, it doesnt move. i dont get it.

Hi Sonet,

transform.position is of type Vector3. When a Vector2 objects gets converted to a Vector3 object, its z-component becomes 0.

If your transform.position.z is 0, and targetPosition.z is != 0, your condition gets evaluated to false. Make sure that the z-position of your waypoints and your enemies is 0.

1 Like

THANKS
i changed my move towards to a vector 3 and it works now.

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

Privacy & Terms