The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Hello, I'm new to your engine and am working on my first game. In it the player can only move forward or backward(towards right or left on screen). So for this I need that as the player keeps moving forward, he keeps getting more and more nodes ( which are just StaticBody2D nodes player can land and move/jump forward on ). Also, These new progressing nodes should be non overlapping and if possible at a certain minimum distance.

It's in 2D only.

So, to sum up I want somewhat:
1) Random placing of nodes as player moves forward.
2) Non-overlapping
3) Infinite

EDIT: Is this (or somewhat like this) is what is called procedural generation?

Please suggest me some ways or code snippets to do the above mentioned.
Thanks in Advance for spending your precious time in helping me out in my problem

Godot version 3.2.3
in Engine by (94 points)
reshown by

1 Answer

0 votes
Best answer

I solved it myself after several days when no one replied. :\

by (94 points)
selected by

please share your result

Basically what you do is...
Create a RandomNumberGenerator and then you use the generated numbers according to your specific needs.

In my case, I assigned the randomly generated number to co-ordinates of pixels on screen and to maintain a certain distance between the nodes, I checked if every next generated number was at least that(the certain distance) much greater than the last one, if not you generate again, or simply add the remaining distance needed to achieve the separation, which has to be calculated for every node.

You can see this example in play in my project here: https://anuragsingh.itch.io/test-project-bunny-maniac

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.