Endless - 2D Terrain Generator

This asset is now free. I no longer have time to support that asset, but hope someone finds the source code useful. Enjoy!
For anyone interested in my other projects, you should check out TrueNovelist, a site to help you organize and structure a novel. It could also be used to help you structure game notes, background info, etc.

I got started with Unity a few months ago, and decided I want to make a game similar to Hill Climb Racing for android. The problem was, I couldn’t find any code anywhere that would let me dynamically generate hills for an infinite runner. If I could have found an asset to do that, I would have bought it…but since I couldn’t, I decided to create my own.

Here it is! Endless - 2D Terrain Generator in Asset Store

1397576--72331--$endless.jpg

Features

  • Dynamically generated terrain - can easily change look and feel for rapid prototyping
  • Full C# source code included
  • Can generate terrain at an angle or in a straight line
  • Rule based terrain generation and prefab placement - no coding required
  • Mobile ready! Tested on HTC EVO 3D for android and keeps scrolling smoothly
  • Works with orthographic or perspective cameras, for a 2D or 2.5D look

Demo

Quickstart - Covers more of the setup details

Thanks for checking it out!

Now that a few people have purchased this asset, I’d love to hear what you are using it for. Feel free to post links to your projects/prototypes/etc. that you are planning on using this for!

I have created a limited trial version for anyone who wants to try this before they buy.

It has all the features of the full version, with a few limitations:

o No source code.
o Terrain only generated for a limited distance.
o Watermark “Trial” button in upper left hand corner.

Enjoy!

Hi,
is it easy to change scrolling to have the camera and player-character always at the centre of the screen (instead having camera and player always scrolling away from the centre of the Unity Grid). Camera at the centre and terrain scrolls left/right… or would this change upset functionality of your asset somehow?

Thanks

This would be difficult to change. I can look into it, but right now the terrain generation is based around the x location of the camera and the assumption that the camera always moves to the right, so adjusting it to keep the camera in one spot and scroll the terrain would take a significant amount of time.

Right,
because I am worried about issues mentioned in other forums on similar subject where the player moves far away from the centre of the coordinate system and precision is lost, I cannot remember the details but I remember there could be issues… unless this is an old problem solved in latest versions of unity or a problem that would only occur so far away from the centre of the coordinate system that the player would actually never get there.

If I am talking about a no issue sorry I don’t mean to disturb your thread
Of course if you could add to your package the option of scrolling either left or right during gameplay and keep camera centred it would be cool features to have anyway that should add value to your asset anyway (I think)

Thanks

You’re right, it is a potential problem. I will look into moving everything back to the origin every couple thousand units, which should be easier than keeping the terrain constantly scrolling underfoot, and should also fix the problem. I’ll let you know if I am able to get that working and update the demo example so you can try it out.

Excellent yes that would be an efficient solution

Your asset is on my buy list will get it soon for my next endless runner project :slight_smile:

Hi, I was just wondering if there was a way to essentially turn some prefab rules on and off after a certain length of mesh has been generated. I’m using the prefab rules to generate enemies for the player and want to turn them off for a boss fight I want in the same scene. Would this be possible or would I have to find a work around.

I am actually just getting ready to submit an update to the asset store that allows you to limit prefabs to a certain distance or a certain terrain generation rule. It usually takes about a week to get an update approved by the asset store though…if you already bought the asset, send me your invoice number and I can email you an advance copy with the changes.

Wow, thanks for the quick update. I went ahead and PM’ed you my invoice number.

Hi Neil
any update on Moving camera/scene back to centre of grid automatically?
or on scrolling while camera/player remain at centre of screen?

Thanks

No, I’m afraid not. I’ve been pretty busy at work and haven’t gotten much a chance to work on this, especially since it is such a large change. Once I do get started on it I’ll let you know though.

ok thanks

Not sure if the new version is out but i am going to PM you my invoice as well :slight_smile:

Yes, the new version (1.1) is out, so if you update to the latest version you should get those features.

@ProjectOne - Just so you know, I am working on the terrain shifting back to the origin. I have able to get the terrain itself to shift automatically, but after moving the prefabs it is completely messing up my prefab generation rules. I’m not sure what an ETA on this would be since if I don’t get it done this week I will be out of town for several weeks on a work trip, but I’ll keep you updated.

sure, thank you for the update

Hi again. I’ve tried out your latest version and its working great for me. What I’m wondering now is if its possible to have multiple prefabs in the same rule and have that rule be able to switch between the prefabs. What I’m trying to do is have different enemy types within a level and not have them overlap on each other, since they do different things to the player. The only thing I can think of is create a long list of prefab rules that switches prefabs based on the distance, but I’m hoping there’s an easier way to do this.

That isn’t something that is supported. If you don’t mind adjusting the code a bit, you could setup two rules for the prefabs (say one for every 5 units and then one for every 10).

Then in the prefab manager class, before you instantiate the prefab you could search for all other game objects nearby and if there are any too close then don’t instantiate the prefab (but still update the rule.lastprefablocation). That would prevent you from placing overlapping prefabs.

              if (pq.angle >= rule.MinSlope  pq.angle <= rule.MaxSlope  allowedForThisTerrainRule  meetsDistanceReqs)
                                {
                                    //Check here to see if there are any other prefabs of x type within a given distance
                                    //If so, don't instantiate the prefab (but do still update the rule.lastprefablocation)
                                    rule.InstantiatePrefab(pq.location, PrefabManagerObject, Pool, pq.angle);
                                    rule.LastPrefabLocation = pq.location;
                                }

Hope that helps.