How do I make enemies spawn outside player camera while moving?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By joshsesdoyro

Hello! Im new to Godot and I’ve been able to solve most problems by drowning in google searches and tutorials, but this problem I really can’t/don’t know how to fix.

So basically I made a top down view game. At first I had a fixed camera view and the player would move around the limits of my camera view. I added enemies to spawn outside of my camera view which worked perfectly.

Now I’ve decided to attach my camera to my player and make the map infinite without boundaries. Ive done that and my player is now in center always moving around the endless map, but the problem now is the enemy spawn location. While my player is able to move endlessly anywhere, the enemies are still spawning in the set location where it used to be.

How do I make it so that the enemies still spawn outside of my camera view while moving around anywhere?

I can’t find any tutorials for it. Any advice?

Thanks in advance!

make enemy spawn at:
your old set location + camera position
so spawn location change along with camera position

sry295 | 2022-04-11 02:02

:bust_in_silhouette: Reply From: Gollum

Hello there. I’m also new and someone better than me will write the answers later. I suggest solving this problem as follows. Let’s say the enemies have a certain position. The coordinates of the camera or player are added to the coordinates once each time an enemy appears (Enemy.x + = Enamy.x + Player.x). You can also add value to display it outside the camera. I hope you find a solution to the problem if you think about it a bit.

:bust_in_silhouette: Reply From: LordViperion

You Can get the edge of screenspace coordinate and convert to global space coord ,after this done add a little offset in outside direction and set the Vector z tag whatewer you want.
Sorry for my weak english.