# Endless Climber

**URL:** https://discussions.unity.com/t/endless-climber/62788
**Category:** Questions & Answers
**Created:** [February 9, 2013, 5:29pm UTC](https://discussions.unity.com/t/endless-climber/62788 "2013-02-09T17:29:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![john-essy](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/john-essy/32/303185_2.png) [@john-essy](https://discussions.unity.com/u/john-essy)
#### Post date: [February 9, 2013, 5:29pm UTC](https://discussions.unity.com/t/endless-climber/62788/1 "2013-02-09T17:29:42Z")

</div>

Hi guys thanks for looking.

I have a question that i have been thinking about all day.

I want to create a game that allows you to jump from platform to platform but have the platforms constantly be created in an upward and side ward direction. I have already created the pooling system so that we are not creating and destroying a lot of objects.

The thing i am finding hard to conceptualise is being able to dictate where they are created(Left, right, up, down) so that the player can go in any direction and there will always be a platform that he can get too.

The main thing that pops in my mind is. How do i know where to place it and before i place it make sure that there is not another block in the way.

The second thing is that if i am falling to the ground how will i be able to dictate, Create a block below you.

I am just finding it hard to design this so that i have complete control but it is also totally random.

Any ideas would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![swordofnoah](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@swordofnoah](https://discussions.unity.com/u/swordofnoah)
#### Post date: [February 9, 2013, 10:26pm UTC](https://discussions.unity.com/t/endless-climber/62788/2 "2013-02-09T22:26:46Z")

</div>

Random Procedural generation where there is always a way to continue is very difficult.  
However in a short amount of time I managed something similar. It looks very “uniform” but its pretty effective and you can improve it if you want. Here’s the code

```
// How high above the player each platform is
var genHeight = 3.0;
//Initialize varibles
var upr = false;
var upl = false;
var ri = false;
var le = false;
var uprCube;
var uplCube;
var riCube;
var leCube;
var thePlayer;
//Find the player if he wasnt set in te inspector
function Start() {
if (thePlayer == null) {
thePlayer = GameObject.Find("Player");
}
}
function Update () {
//Check if we nedd to generate a platform in the top right
if (upr == false) {
	uprCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    uprCube.transform.position = thePlayer.transform.position + Vector3(1,genHeight,0);
	upr = true;
	}
if (uprCube != null) {
if (uprCube.transform.position.y <= thePlayer.transform.position.y) {
upr = false;
ri = false;
}
}
//Check if we nedd to generate a platform in the top left
if (upl == false) {
	uplCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    uplCube.transform.position = thePlayer.transform.position + Vector3(-1,genHeight,0);
	upl = true;
	}
if (uplCube != null) {
if (uplCube.transform.position.y <= thePlayer.transform.position.y) {
upl = false;
le = false;
}
}
//Check if we nedd to generate a platform in the below the player to the right
if (ri == false) {
	riCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    riCube.transform.position = thePlayer.transform.position + Vector3(1,-1,0);
	ri = true;
	}
if (riCube != null) {
if (riCube.transform.position.x <= thePlayer.transform.position.x) {
ri = false;
}
}
//Check if we nedd to generate a platform in the below the player to the left
if (le == false) {
	leCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    leCube.transform.position = thePlayer.transform.position + Vector3(-1,-1,0);
	le = true;
	}
if (leCube != null) {
if (leCube.transform.position.x >= thePlayer.transform.position.x) {
le= false;
}
}

}

```

I probably over complicated things but it works pretty well (it needs some improvement.) If you want to see my sample project heres the dropbox [1](https://www.dropbox.com/s/7fo3mi8uvu00zoe/New%20Unity%20Project%201.rar). In the mean time. Happy coding!
