Procedural Terrain Generation with AdvancedRandom

0 favourites
  • 4 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hi guys,

    Im doing a procedural terrain generator in C3, wich works perfectly, but as im using AdvancedRandom plugin, the noise output is creating my islands randomly.

    The problem is, i want centered islands, always generate terrain form a center point.

    Ive seen other people, in other game engines, using radial gradients, to "lock" the noise to a center point, but i dont know how to port it to Construct.

    These are screenshots from my current generator:

    And what im trying to achive is this:

    Its from this web: medium.com/@travall/procedural-2d-island-generation-noise-functions-13976bddeaf9

    How can i generate this type of gradient:

    So i can substract it from the noise, like in this image:

    Thank you!

  • You don't actually need that image to solve the problem. All you need is to know the distance the pixel is from the center of the image. Here is a simple project built off the Noise Textures built in example:

    drive.google.com/file/d/1A1jzWoIMUB5N3A0cF1GmfRzEnMWsHHn9/view

    Notice the event the sets the pixel:

    -> System: Set NoiseValue to (AdvancedRandom.Classic2d(XIndex, YIndex)

    - (distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2) ÷ 400))

    × 100

    I am subtracting the distance from the center:

    distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2

    divided by 400 which is the max distance of an edge to the center in this example:

    (distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2) ÷ 400))

    It's super simple but kind of math heavy. Hopefully it helps though. Good luck with your project.

  • You don't actually need that image to solve the problem. All you need is to know the distance the pixel is from the center of the image. Here is a simple project built off the Noise Textures built in example:

    https://drive.google.com/file/d/1A1jzWoIMUB5N3A0cF1GmfRzEnMWsHHn9/view?usp=sharing

    Notice the event the sets the pixel:

    -> System: Set NoiseValue to (AdvancedRandom.Classic2d(XIndex, YIndex)

    - (distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2) ÷ 400))

    × 100

    I am subtracting the distance from the center:

    distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2

    divided by 400 which is the max distance of an edge to the center in this example:

    (distance(XIndex, YIndex, LayoutWidth ÷ 2, LayoutHeight ÷ 2) ÷ 400))

    It's super simple but kind of math heavy. Hopefully it helps though. Good luck with your project.

    Hi InDWrekt, it worked perfectly.

    I got everything working as i wanted, take a look.

    Exactly what i wanted, and it worked with just a few modifications, to work with my generator.

    Thank you very much, very helpful ^^

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Dude, that looks great. Glad I could help. Good luck with your project.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)