Search Unity

Allow sphere in colliders only

Discussion in 'Physics' started by piggybank1974, Mar 8, 2019.

  1. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    I'm trying to figure out a way to only allow a sphere(s) to appear in the series of joined box colliders see Screenshot, I've set up.

    I've written some test code to see if I hit a collider using the Physics.Raycast with a layer mask, But I cannot figure out how to make sure the Physics.OverlapSphere would check to see if it's ONLY within the bounds of it.

    One idea was I could do a series of colliders that circle the other colliders and if the Physics.OverlapSphere hit one of these I know it's not within the bounds. This is only for the editor part as when a user runs it the Sphere's/Trees will already be created.

    Cheers.
     

    Attached Files: