Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Projectiles penetrating wall corners

Discussion in 'Physics' started by akuno, Dec 30, 2016.

  1. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    I have a 5x5 grids, with 5x5 walls. When I shoot a projectile in the corner in a certain angles, it always penetrates between the colliders.
    I tried changing to 5x5 grids with 6X6 walls, but no luck:

    The projectiles are 0.4x0.4x0.4 in dimension.


    ALLCONNECTED.jpg
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    Have you tried enabling Continuous Collisions on the projectiles?
     
    akuno likes this.
  3. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    Yeah, they are continuous dynamic. They are also penetrating with just continuous. I also tried disabling interpolation, in case it somehow could be interpolated inside the corner, but also no luck. The projectile is a cube collider.
     
  4. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    It seems that it is a issue with the box corners.
    I am accelerating that projectile with AddForce(transform.forward * 500);

    Any ideas someone?

    2.jpg 3.jpg
     
  5. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    I managed to reduce the collision discrepancy by changing the fixedUpdate to 0.01. But the projectiles are still not colliding with a part of the box corner.

    Is it supposed to happen even with a continuous dynamic collision detection? The projectiles can still penetrate through building meshes, which is an undesired behavior.


    2.jpg
     
  6. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    The only solution I can think of is using a physics raycast every time you fire to see if the projectile will collide with the wall. However, a raycast is just a straight line, so it would require some calculations to account for the projectile drop due to gravity.
     
  7. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    It would probably be better to use Physics.SphereCast. But it really shouldn't be necessary! Continuous collisions ought to solve the problem.
     
  8. Ramaraunt

    Ramaraunt

    Joined:
    Dec 17, 2016
    Posts:
    77
    What I would do, is place a sphere in there. Problem solved! :D