Procedural generate landscape levels

Hi everyone hope all is well today. So I’m look to procedural generate landscape levels for my endless runner. And I want to have multiple level containing there own landscapes how would I be able to procedural generate these seamlessly like the actor spawning method. Thank you for your time and I appreciate any and all answers.

Probably the easiest and only way that I know how to do, is by using the “Procedural Mesh” component. It lets you create and modify mesh sections during runtime (Unsure if it updates collision at runtime). I found this video on youtube which creates a simple plane using this component:

https://www.youtube.com/watch?v=dKlMEmVgbvg&t=2s

Hope this helps :slight_smile:

This looks nice but it’s not what I’m going. I want to be able to paint textures add tree add ai to my level and etc. But if this method is still able do do all of that then please let me know and if you don’t mind can you show a small demo for it so I can have a deeper understanding of it. I found a set level transform which can help with the location but I that is as far as I got.

Adding trees and AI would be simple. Just get the location of the character, probably further forwards in the terrain to make it out of sight from the player, then trace down to the terrain and spawn them.

When it comes to texturing a procedural mesh, the way it works is you get a vertex point of the mesh and apply a color to it. So for really detailed textures your mesh would need to be a very high resolution, which is possible, but very demanding.

Also one thing to keep in mind, is that by just creating a flat plane of terrain you can’t really add texture to anything below the surface, so you would also have to add sides to it. This is again possible, but very demanding and hard to code.

Other than this I’m not really sure if what you’re aiming for is possible without using external libraries (like VoxelFarm), which I have no experience with. So unless you’re fine with pre-modeling the level-assets (Like floor, roof, obstacles, etc.) and then procedurally place these in the level at runtime, I’m afraid I can’t help you, apologies ;(

Hope this was helpful!

First I’m very appreciative of the suggestion and I’ll give this a try and see if I can get a landscape with it and just play around on it. No need to apologize I’m looking to do this in the engine it self so if this works out for the job then awesome.

Also how would I get the ai to move without the nav mesh cause to move the ai you need one if you could explain how this is acompished that would be awesome.

As for textures can you explain more on it this is something I haven’t done and can you go in detail but simple please. My apologies if this is difficult or if I’m being difficult.

Not quite expierienced with AI not using navmesh, but what you could do is apply force to them towards the actor or whatever desired direction, and animate based on their current velocity, aggression state, etc.

Also, you can still use navmesh even though the terrain is infinite. For making navmesh work globally I suggest you use navmesh invokers. Navmesh invokers are basically actor-components that only updates the navmesh in a certain radius around its owner. Performance-vise, this is how games like ARK: Survival Evolved handles nav mesh in their big open worlds.

Steps to setup a navmesh invoker:

  1. Enable “Generate Navigation only around Navigation Invokers” in Project Settings->Navigation System.
  2. In your AI-actor, add the component “Navigation Invoker” to your actor.

So, for your textures… Your textures are stored in an array of linear colors, in which the index of each element of that array corresponds to the index of each element in your array of vertices. In order to set a particular vertex’ color, you need to get its index in your vertices-array, and set the element in your color-array with that same index to your desired color.

To be honest, thinking about it now I don’t think using the procedural mesh component is your best bet here, I’m just saying it’s the only solution that I know of if you want to create procedural terrains. One of the few problems using this workaround is also that the procedural mesh component doesn’t update collision during runtime, which is pretty sad ;( So pretty much, without having a fixed terrain (that does not auto-generate during runtime), it can’t do what you want to approach.

I don’t really think I can participate much more, as procedural mesh components are quite new to me aswell, so I wish you good luck looking for the solution that you need. Hope this helps :slight_smile:

Thank you I’ll do that. I found what I was looking for it was the “Load Level Instance” node it has a location and rotation pin for in put so you can have levels with landscapes in them and load the same one over and over if you desire.

No problem, glad I could help :slight_smile:

I’m using procedural meshes to generate the terrains. The performance is cancerous with 2fps