Help with spawning tiles based on player location

Hello everyone, I’ve run into a standstill on a project I’m working on. Forgive me in advance if I sound unclear or improperly use jargon, all of this is very new to me.

What I’m trying to achieve is an endless staircase going up and down, but I’m a bit at a loss at how to do this.

Currently I have a section of the staircase in a blueprint that works exactly the way an endless runner does, but I’ve been struggling to find a good solution for when the player wants to go back up the staircase. The spawning and deleting of tiles based on player contact with collision boxes has been really messy. I figured a better way to approach the situation would be to have a staircase tile spawn and delete itself based on player location rather than from hitting collision boxes, but I couldn’t find any resources online on how to do that. I am hoping there is a way to spawn these staircase tiles above and below the current tile(s) based on where the player is on the z-axis.

Does anyone have any insight into this? Thanks!

You could do it based on player Z height, but I think collisions boxes are easier ( hear me out :slight_smile: )

I bet you did it with two collision boxes, right?

I think it would work with one in the middle of the stairs. You just spawn when the player leaves the box. You can tell where to spawn from the height of the player relative to the box.

1 Like

The function is

And a bit of a hacky way of getting rid of unused stairs

Works pretty good :slight_smile:

stairs

1 Like

This is awesome, thank you so much!

You are right that I was using two collision boxes, my staircase blueprint was really two staircases conjoined by a platform with a collision box on different parts of the stairs. This was to try and create the illusion of a never ending staircase without seeing the other tiles spawn in or delete themselves above and below.

In the same way I can set it to spawn from the height of the player relative to the box, I can also set the tiles to be deleted from the height of the player relative to the box, right?

1 Like

You could set the spawn / unspawn relative to the box.

If you don’t want to see it happening, though, just use a longer staircase :slight_smile:

I’m testing this out now and am having some trouble getting anything to spawn now. Do you know what I am doing wrong here?



Thanks again!

Try temporarily disconnecting this

or increase the distance a bit. I had that problem. It is spawning, then immediately removing it.

This solved the issue, but now I can’t pass through the collision box anymore, and the staircases are spawning in a different spot. Weird

1 Like

Well, it wouldn’t cause that though, eh? :slight_smile: