Object spawning near player

Hello guys,

I came to ask something:

I am making a endless runner with the world moving towards the player and i am not sure how to make spawning of obstacles (Note: i am not looking for scripts just hints). My idea was to instantiate them in a set distance from the player (Since the player is not actually moving i guess they can be created in the same distance from him forever so i dont need to change the Z coordinate with each spawn).

Basically what i want to do is to spawn them in a set distance from the player (but on random X position and set Z and Y positions) and set raycast to the sides to ensure they are not overlapping each other when they spawn. Can i do it this way or is there some better way?

what sort of obstacles?

If it was like a tree across the path then this would be 1 object that then would move towards the player so there would be no chance of have 2 of them overlap.

If it was a crate or boulder and you wanted more than 1 spawning across the x axis at once then it would be an issue.

Well they dont have to spawn at once. Simply one after another. Basically one spawns on the X axis and moves and another obstacle spawns somewhere on the X axis and moves and repeat.

what have you got so far?

meh

Well, as for the game itself, almost everything (programming wise of course) (this is the only thing missing) as for code to this, nothing. I am planning and thinking the code first then i try to implement it.