Currently I am using random positions outside of camera view to spawn my enemy. I want to spawn my enemies in selected areas:
How can I do that?
CodePudding user response:
What you should do is send a raycast from your camera and check if the ray hits the area you don't want it to spawn on. If it doesn't hit it, allow it to spawn, but if it does discard the current position and try again.
CodePudding user response:
Set a Trigger collider to the area and stop the enemy spawn there