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

Objects Collision Detection from Single Script? - Procedural Level Generation Question

Discussion in 'World Building' started by ToritoGames, Nov 1, 2018.

  1. ToritoGames

    ToritoGames

    Joined:
    Apr 17, 2016
    Posts:
    9
    Hi,
    I am trying to create a procedural generated space and I couldn't find a solution to the next problem:
    - The spawned scale, rotation and transform might vary.
    - I need that none of the objects touch each other when spawned

    How is the best way to handle this? I was thinking about adding reference to those objects into an array and then run through all them while relocating those that are hitting other. But so far I couldn't find any help regarding how to check those collisions from a single script and in the same script iteration (without having to wait for the next frame and making the objects self send the collision information to the main script).

    Is there some way to do this? And if not, what is the best practice to achieve what I am trying?
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
  3. ToritoGames

    ToritoGames

    Joined:
    Apr 17, 2016
    Posts:
    9