I'm working on a dungeon generation script and I'm having some issues detecting overlap. Each piece that I spawn has attachment points, with rotation values and an offset amount so things lineup correctly. So far this is working. After spawning, I then check to see if the piece is overlapping with another, but sometimes it seems like unity hasn't caught up with the collision system, as I check to see if a bool bOverlap is true(which gets set in an ontriggerstay function) and if so destroy the piece. However, many times the script will have gotten past this collision check portion, before the collision event fires.

Any suggestions?

Each piece has a rigidbody and box collider on it for the simple collisions.

  • \$\begingroup\$ Can you post the relevant part of the code? Where do you spawn each object and how do you move it to the relevant position? I'm confused why you need to check for collision, if you've already figured out attachment points and rotation. \$\endgroup\$ – iQew May 11 '19 at 9:50
  • \$\begingroup\$ Have you tried checking for overlap before you spawn, with Physics.OverlapBox? \$\endgroup\$ – DMGregory May 11 '19 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.