Pseudocode enemy AI

This is what I got:

//enemy AI

    Vector2 toTarget{Vector2Subtract(target->GetWorldPos(), worldPos)};

    toTarget = Vector2Normalize(toTarget);

    toTarget = Vector2Scale(toTarget, speed);

    worldPos = Vector2Add(worldPos, toTarget);
1 Like

Looks good. Does it work properly?

Privacy & Terms