Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Options for overhang detection during procedural object spawning

Discussion in 'Game Design' started by joesobo, May 7, 2020.

  1. joesobo

    joesobo

    Joined:
    Sep 6, 2018
    Posts:
    17
    I'm trying to make a tool for procedurally generating objects on my terrain.

    Generally spawning works fairly well, but I'm trying to figure out how objects that spawn on edges of cliffs and sharp edges can be detected and avoided. Objects that overhang basically.

    Right now I already use a raycast to check for a position to spawn the objects. The only way I can think to do some sort of overhang detection would be to cast 4 more downward rays from each corners of the object, creating a plane. If that plane intersects the terrain than its not flat.

    But this is just checking if the square underneath the object is uninterrupted, not necessarily only overhanging objects as a bump under the object would cause it to fail. Plus 4 more raycasts is quite an expensive road that i'd like to avoid. If anyone's got some suggestions for a better idea I'd love to hear it.
     
  2. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    2,968
  3. joesobo

    joesobo

    Joined:
    Sep 6, 2018
    Posts:
    17
    What if the terrain is not using Unitys terrain. I made a custom Blender planet that i am spawning my objects on.
     
  4. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    2,968
  5. joesobo

    joesobo

    Joined:
    Sep 6, 2018
    Posts:
    17
    okay that helps a bit with meshSpawning, but i'm working with raycastSpawning. And also how is that relevant to overhang detection?
     
  6. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    2,968
  7. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    Does your scene have a navmesh? I Find the closest point to my spawn location that’s on the nav mesh.
     
unityunity