Attack that warps to nearest enemy but shoots forward if none are nearby?

How would you approach this?

You could have a homing projectile (turn on homing in projectile component) and a non homing one, if there’s an enemy within range spawn a homing one, if not, a forward one. Or just turn homing on/off on the projectile.

Could do the distance checks in a number of ways. Like a detection sphere and check for overlapping enemies.

Try this: https://www.youtube.com/watch?v=uVbwhm5gHXo