I am making a game that has a never ending terrain and constantly updating i want zombies to spawn from a distance where player can and cant see please help me…
I want zombies to be spawned like a 200 block radius and can stay on the map.
I am making a game that has a never ending terrain and constantly updating i want zombies to spawn from a distance where player can and cant see please help me…
I want zombies to be spawned like a 200 block radius and can stay on the map.
spawn the “thing” using this, but to get the “distance where player can and cant see” part then you might need to do some work.
assuming a flat area that the player is standing on then you just constrain your y, and get random values for your x, and z values of the position. just use
Vector3 position = Vector3.zero;
position.x = Random.Range(player.position.x-xVary,player.position.x+xVary) // player is the transform of the player, and xVary is a public float (for balancing)
but before you use that vector in the instantiate then you might want to do a Physics.RayCast() to see if that would be in line of the player (if there is a lot of things around the player like dense forest this might get tricky), but for the not off the edge of the world thing just do a RayCast(position, Vector3.Down)
mind you that this was assuming a large flat area, and if you have a lot of hills, or uneven terrain then this will require a fare bit of modifications