Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Infinite Terrain - Free Project Source

Discussion in 'Made With Unity' started by Quickfingers, Nov 28, 2010.

  1. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Hey folks , here's a little experiment I put together to give something back to the community.



    It's an infinite terrain generator. Using a simplex noise algorithm I created an infinite terrain that just keeps on going no matter how much you move

    You can adjust the height and detail values but obviously due to the random nature. Controlling it much more than this is pretty tough. Anyway I've uploaded the web player so you can see if this is something that would be useful before commiting to the epic 300kb download ;)

    Enjoy!

    Web Player : http://quickfingers.net/scratch/2010/infinite_terrain/

    Download : http://www.quickfingers.net/scratch/2010/infinite_terrain/infinite_terrain.unitypackage
     
  2. Dreeka

    Dreeka

    Joined:
    Jul 15, 2010
    Posts:
    507
    This is pretty interesting.
    You should add some extras like trees, grass and so on,

    Keep up the good work :D
     
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Wow....interesting indeed... you now that this can be used to creating infinite ocean...
     
  4. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Thanks for sharing, I'll give it a look.
     
  5. RoyS

    RoyS

    Joined:
    Jan 12, 2009
    Posts:
    664
    "Random nature" - so no two will ever be the same? Pretty awesome. Thanks for sharing! Nice gift!
     
  6. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    pretty slick, though from the web player it just looks like it tiles the terrain over and over, don't know if that's true but the random foliage should help that. fog looks pretty darn cool, all neon green and what not.
     
  7. pilypala

    pilypala

    Joined:
    Jan 13, 2011
    Posts:
    8
    awesome job dude. exactly what I am looking for.
     
  8. pakdebyl

    pakdebyl

    Joined:
    Jan 12, 2010
    Posts:
    6
    Thanks - exactly what I was looking for.
     
  9. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    It will eventually tile due to the non-4reals-randomness of random number generators! You can effectively hide this by combining noises with scale and rotation offsets.
     
  10. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    Waow, i was looking for something like this !
    Thank you very much for sharing that resource. It will be very useful for many of us.

    Very good job.
     
  11. lusho_games

    lusho_games

    Joined:
    Jun 4, 2011
    Posts:
    63
    thanks for sharing this tool !, I really dig all the quickfingers games.
     
  12. Vinícius Sanctus

    Vinícius Sanctus

    Joined:
    Dec 14, 2009
    Posts:
    282
    Awesome share my friend! If you want to check it out in my game just check the link on my signature! =D

    Thx a lot, community appreciate your awesome share! =D
     
  13. t.a.aa

    t.a.aa

    Joined:
    Dec 4, 2012
    Posts:
    1
    A newbie question: how do I use your unity package into a fresh scene?
     
  14. adrenak

    adrenak

    Joined:
    Aug 17, 2012
    Posts:
    49
    Really good contribution to the community. Cheers!
     
  15. MadRobot

    MadRobot

    Joined:
    Jul 12, 2011
    Posts:
    339
    Oh nice work! Also, I love your avatar!
     
  16. niraj

    niraj

    Joined:
    Feb 14, 2013
    Posts:
    56
    Fantastic Work friend. I am going to test :) You did really great Job for community.
     
  17. niraj

    niraj

    Joined:
    Feb 14, 2013
    Posts:
    56
    Hello Quickfingers,

    Can you help me little bit. I am getting following error when i have replaced camera with another character in the scene:

    IndexOutOfRangeException: Array index is out of range.
    TerrainGenerator.Cull (Int32 changeX, Int32 changeZ) (at Assets/Infinite Terrain/Scripts/TerrainGenerator.cs:127)
    TerrainGenerator.Update () (at Assets/Infinite Terrain/Scripts/TerrainGenerator.cs:168)

    PLease Help
    :
     
  18. wwsamson

    wwsamson

    Joined:
    Jul 24, 2014
    Posts:
    2
    How do I use it?

    If I drag the terrain plane into my game and then attach the terrain generator script into it and set the terrain plane to the gameobject of terrain plane and the target to an object, when I try to play it the game lags out and apparently tries to generate an infinite amount of terrain at once, using up all of my memory and I have to kill Unity in Task Manager.
     
    Last edited: Aug 11, 2014
  19. nomadic

    nomadic

    Joined:
    Mar 4, 2010
    Posts:
    44
    wwsamson, late replay but...
    It sounds like your problem is that you have the Generator script attached to the piece of terrain which gets cloned. This means that each chunk of terrain is also trying to generate it's own set of chunks, which of course is an infinite loop.
    You need an empty GameObject with the Generator script on it, then plug in the terrain plane to that.
     
    Last edited: Feb 6, 2015
  20. wwsamson

    wwsamson

    Joined:
    Jul 24, 2014
    Posts:
    2
    Thanks!
     
  21. ashishact

    ashishact

    Joined:
    Oct 13, 2014
    Posts:
    1
    Thanks a lot.
     
  22. Bakkernils

    Bakkernils

    Joined:
    Nov 18, 2014
    Posts:
    30
    Thanks! works really well :) nice job
     
  23. InFa

    InFa

    Joined:
    Feb 7, 2015
    Posts:
    1
    cool... nice work
     
  24. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    anyone got any working link ?? plz share here
     
  25. andrew_fundscomein

    andrew_fundscomein

    Joined:
    May 3, 2015
    Posts:
    2
    Thanks! This is awesome!
     
    SAOTA likes this.
  26. Xitech_

    Xitech_

    Joined:
    Feb 19, 2013
    Posts:
    140
    Awesome! Thanks!
     
  27. Wilelle

    Wilelle

    Joined:
    Jun 16, 2015
    Posts:
    93
    This is great! But I can't get it to look like in the web player. Could you, or anyone, give me some help with how to set things up to make it look right?
     
  28. DocEntropy

    DocEntropy

    Joined:
    Jan 6, 2015
    Posts:
    3
    Hey, this is great :D Thanks a lot for this script! Brilliant!

    I have a question though: if I wanted to move everything back to origin once the player has reached a certain distance, how would I go about using your script?

    I tried changing the transform of all children to go back a certain distance, it works but then the script stops due to the following error:

    IndexOutOfRangeException: Array index is out of range.
    TerrainGenerator.Cull (Int32 changeX, Int32 changeZ) (at Assets/Infinite Terrain/Scripts/TerrainGenerator.cs:129)
    TerrainGenerator.Update () (at Assets/Infinite Terrain/Scripts/TerrainGenerator.cs:176)

    Any help would be appreciated! Thanks!
     
  29. Hamzii

    Hamzii

    Joined:
    Mar 13, 2016
    Posts:
    1
    I need to attach procedural generated trees on this terrain so as the player moves the trees are showing up at random places. need help, anyone ?
     
  30. z3nth10n

    z3nth10n

    Joined:
    Nov 23, 2013
    Posts:
    55
    8 years has passed from the first release, and 4 years ago I used this for first time. I still use this because use Meshes is a very interesting approach.

    I have refactorized it and make it working:

    https://github.com/z3nth10n/Infinite-Terrain

    I only see a problem, this is not infinite due to floating point precission error. Maybe implemeting this: http://wiki.unity3d.com/index.php/Floating_Origin could solve the problem (you may need to cheat the system, by having two inputs, one for the Noise Lib (in double type) and another for the current position, telling how many "frontiers" you have go throught).

    Double type has it's precission limit on 30,000,000,000.
    Float type in 100,000.

    So, if you go to the precission limit of the double type, you will travel 300,000 "floating frontiers", this can be stored on (int) xLimit, yLimit values.

    When you reach a the position 100,000 on any direction, you can increment this (xLimit or yLimit variable). And when you try to get the height for this position you could do (xLimit * 100000d + currentPos.x, for the X axis, and the same for the Y axis).
     
    Last edited: Oct 27, 2018
    jjstin likes this.
  31. poyapaya12

    poyapaya12

    Joined:
    Apr 20, 2020
    Posts:
    5
    I can't download that