Home > Blockchain >  I want to spawn Enemy's in random position in given area. I don't want to spawn my enemy&#
I want to spawn Enemy's in random position in given area. I don't want to spawn my enemy&#

Time:12-17

Currently I am using random positions outside of camera view to spawn my enemy. I want to spawn my enemies in selected areas:

Game screenshot showing area where I do not want to spawn enemies

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

  • Related