Best way to keep objects from overlapping

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Guten tag,
    so I'm making a Sandbox game and I've set up a pretty basic tree generator, however there's a problem where trees just overlap each other.
    when i set up a line where it destroys when overlapping, i feel like not enough trees Generate.

    is there any possible way I could keep them from overlapping and spawn in better places? or better yet have them spawn in play areas instead?

  • So I assume that at the moment you're placing them completely randomly. One thing you could do is something like this:


    Please login to see this picture.


    That would create them in a semi-randomised way. They would be spaced 50px apart on average, but each individual tree would have 40px of randomised variation within that. Here's what it looked like when I ran it:


    Please login to see this picture.


    Because it's not entirely randomised, the spacing is likely to look a little artificial (ie. not 'patchy' enough), so you may want to create a few more genuinely randomised trees on top of that. And possibly delete a few random trees too, to create a few gaps.


    Another thing you could do would be to find overlapping trees, but instead of destroying them, just re-randomise them. Perhaps run a fastloop 5 times or so where you re-randomise a tree's position and re-check for overlap. If it still overlaps another tree after 5 tries, then destroy it (but hopefully most trees would have randomly found a suitable non-overlapping spot before the 5th try).

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

    Edited once, last by Volnaiskra (November 7, 2023 at 3:40 AM).


  • Another thing you could do would be to find overlapping trees, but instead of destroying them, just re-randomize them. Perhaps run a fast loop 5 times or so where you re-randomize a tree's position and re-check for overlap. If it still overlaps another tree after 5 tries, then destroy it (but hopefully most trees would have randomly found a suitable non-overlapping spot before the 5th try).

    Just another question, how can I check if a Loop is over again to do it? and will just randomizing the X and Y pos work?

  • Fusion won't progress to the next event until a fastloop is finished. So if in the example I screenshotted above there was an event #4 that played a sound, the sound wouldn't play until all 10,000 loops were finished from events #1-#3 (100 of the first loop multiplied by 100 of the second loop)*. So to answer your question, just do your checking for overlaps in a separate event that comes after your tree-creation fastloops, and it won't run until all the trees have been created.

    I'm guessing that randomising X and Y should work ok. Give it a try and see what happens.


    * Blimey, 10,000 trees - I think I went a little overboard in that example

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!