How to control distance left between two random instances?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kittypowerftw01

Hi all!

First of all, I’m a complete novice when it comes to Godot and game development in general, so bear with me.

Here’s my problem:
I’m making a simple endless runner prototype in 3D. The terrain is constructed of moving blocks (made from KinematicBodies) which are picked from an array at random and instanced into the scene with the help of a timer node. This part works fine, but I’d like to control how much space is left between each block. The only way I’ve been able to control this to some extent, is by increasing or decreasing the spawn time. However, I realize this is not a good solution in the long run and it has its own issues. How would I go about controlling the distance left between the blocks? The simpler the solution, the better.

Thanks in advance!

:bust_in_silhouette: Reply From: Inces

Perhaps the easiest way would be to place a primitive area3d detecting when a block exits its field, and prepare another block in anticipation of that moment. You would be able to choose where segmentally the end of a single block should be detected, and this position would determine space between the real end and beginning of every new block.

That’s a good idea, I’ll see what I can come up with.

kittypowerftw01 | 2022-08-16 06:54