How do I randomize levels in a basic "Runner" game

I asked about how to randomize the levels in a basic Runner game on UnityAnswers and was told this:

I just want to double check if that is how most people do it. Because I know that people like yome (maker of Chop Chop Runner) have made similar games.

Is that how most game developers do it? Or do they do it a different way?

I would do it that way, and destroy the different sections as they went off the play field. Since they won’t ever be used again, no reason to keep the memory taken up.

What’s a runner game? googling Ahhh, also retro gameplay like…

And quite some others as well…

Dino Run is awesome in many ways!

Btw i threw quite some coins into this passive running/walking arcade with the optical crossbow.

Hey and Jungle Hunt qualifies as a running arcade as well, again, so many coins, still with moody sfx.

Hah and Moon Patrol, getting excited, would be a running/driving shooter! Did i mention any coins?

Okay, i stop, for now…

:stuck_out_tongue: Long list. Some of them are off target though. I was a little vague. The one I was talking about would be like this.

That type, where you need to jump from platform to platform.

Good Point. Will do.

One more thing, how will I check when to instantiate a new “chunk” and destroy the old one?

You could check position relative to the player, or use triggers, or things of that sort. For instance, if you make the chunks larger then the screen, then you can destroy the last chunk when you enter a trigger on it, and load the next chunk at the same time. I think based on player position is probably the best one though.

I know how to do the trigger version but how would I do the player pos one?

Could you explain please? I really appreciate your help BTW.

EDIT: Just to double check, each chunk would be a prefab to instantiate right?

Yes on the prefab part.

As far as the player position, you would check the players transform and the different section’s transforms, if they are say 200 units behind the player, then it’s more then likely not possible to be seen by the player anymore, so destroy that sections prefab. It just saves checking for collisions and instead compares two x, y, or z values, whichever direction you have it going. I think the position one is technically faster as it’s just comparing is x <= player.x-200, as opposed to checking the minimum of 8 points and if the value of 8 other points are inside of that range.

I don’t think it matters on something like this because it’s probably not all that graphically intense (most runner style games aren’t anyway) so checking the maybe 10-15 seconds on a collision won’t really matter. :slight_smile: I just try to optimize where I can.

Also, rather then having the trigger collision on each prefab, I’d simply have it surround and follow the player. If it collides, do nothing, if it doesn’t collide, destroy.

As far as complexity in programming, I don’t know which is easier for you personally. The transform position is probably easier to figure out then collision and what it hit and so on. It’s up to you. Whichever you feel more comfortable with.

EDIT: OH, you can also use the destroy check to run the instantiation of the next chunk, that way you only have to do one check.

Oh I get it now. Thanks SO Much! I’m going to attempt the Player Pos version.

Probably going to try deleting the things behind first. After that I’m going to try instantiating at the right time.

EDIT: Now that I think about it, I think I’m going to instantiate on Trigger and Delete by PlayerPos.

Because how would you find out when to instantiate by using Player Pos?

No problem. :slight_smile: I enjoy helping.

Also, I was going under the assumption that all sections will be the same unit size, so you’d simply add the length of the sections onto the instantiate position. Like I said, I would instantiate the new section of the level right before I destroy the last section.

Oh. That would make sense.

Well, I don’t think each chunk will be the same size…more freedom and ways to customize the chunks that way…that could be a problem…

How would I know where to instantiate the new platforms?

I would make a public variable on something like the camera that keeps position and size of the last made object, and set the transform of the new object to the that last objects transform + the size. Then in the start event of the prefabs, set the public variable to the new size and position. At least, that’s how I’d do it.

Make sense?

That would make sense, will try implementing something like that today or tomorrow.

Thanks!