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

Ignoring collision not always working?

Discussion in '2D' started by 0ver, Oct 11, 2015.

  1. 0ver

    0ver

    Joined:
    Jul 5, 2015
    Posts:
    1
    The base of my project is a top-down 2D spaceship sim, which would be easy enough, but the way I want to have it set up is to have multiple parts (objects) as part of one ship. The only major problem I've run into is, since they're separate objects (children of the main ship object), they have their own hitboxes to make sure that whenever they're hit, the proper piece takes damage.

    The problem seems to not always happen, but specifically while rotating/turning the ship it happens quite a bit, and occasionally while flying straight. The objects tend to bounce each other and snap or fling the ship to a different location. I've tried using Physics2D.IgnoreCollision and Physics2D.IgnoreCollisionLayer, which is the current method I'm using that has the problems, but is still much better than not at all which would have it happening with every little movement of the ship. Other attempts have been made by switching off and on the box/polygon colliders that are attached when they collide with objects that have certain tags or types. This problem extends to the bullets that are shot from the ships (spawning underneath them and colliding with the ship, same problem). I've been dealing with this issue and looking for a solution for a few months but moved on, figuring it was just a lack of unity knowledge holding me back, and said I'd come back to it and try again when I had learned some more, but it's to the point where it's hindering the main goals of the game and I can't ignore it anymore. Is there anything I can do about this? Or should I move on and try to find other options?

    I'm not sure if raycasting would be an effective solution for my problem, especially considering I'd have to check for collisions with other large objects, so wouldn't I have to check both ways? I've heard a lot of raycasting can start to cause performance issues if there are enough of them. Any advice on this would be greatly appreciated and I can share more details if necessary.
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    I'm not sure if it's the same as you've tried but have you gone through the menu to set the physics layer checkboxes?