- Home /
2d Random object placement help?
So, I have a game I'm working on that I want to be an endless runner, but I want the obsticles to be randomly placed... Basically the game is you going down a snowy slope and you have to avoid trees, Being an endless runner type of game, I want the obsticles to be Randomly placed only thing is, I'm not sure how I would do this, I tried making 3 different areas that stuff could spawn (Left and Right Edges that spawns very thick obsticles, then the Center that spawns very few.) But this caused basically a strait line of trees and rocks and looked very Linear.. I'm kind of hoping for something looks like the picture below.
If anyone has any ideas on how I could go about doing this, or any tutorials that would show/explain how to do something like that I would really appreciate it! Thanks!
Answer by cjdev · May 27, 2015 at 02:12 AM
One method of generating a look of pseudo-randomness is to separate your random placement into segments to create a more distributed look that still preserves the feel of unpredictable variation. It's a little hard for me to describe so I made the following image to illustrate:
Basically, you create sections and populate those with your random points in order to control the density of points in any given area. In your application you could have areas in the middle of the lane have fewer points spawn but areas on the borders have greater points spawn. The edges of your course would be defined by the position of whatever shapes you chose to contain the portions with the highest density of points (the 'Many Random Points' boxes in the image above).
Your answer
Follow this Question
Related Questions
Spawning objects in infinite scroller game 0 Answers
Random instantiation endlessly? 1 Answer
Making a randomizer script for a basic "Runner" game... 1 Answer
Infinite Runner Tutorial - Destroyer Problem 2 Answers
Procedural runner level creation 2 Answers