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

[UPDATE ] Collisions or triggers nog always working?

Discussion in 'Physics' started by Xercium, May 2, 2016.

  1. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    [Different problem that seems to have somethign to do with this occured, look bottom]

    Hi,

    When I jump onto a certain gameobject, my player penetrates the polygon collider. Also tried adding a small boxcollider to see if that made any difference but it didn't.
    Here's a gif of the problem:

    As you can see the problem isn't alway occuring, whats more is that this is the only object that has the problem, all other ground objects seem to work as intended.

    Here are my colider setups:
    (EDITED: wrong rigidbody settings)




    Thanks for the help guys!
    Hope I provided you with enough information.


    [NEW PROBLEM]

    MelvMay, it seems my problem is re-occuring with my bullets.

    I have 2 types of bullets and the problems are I think simular in solution but the effect is somewhat different.

    My first bullet type is a fireball, it just moves in straight lines, when colliding with a player it is destroyed unless it's the player who fired the bullet, if it collides with another bullet or object or ground it should be destroyed aswel.
    Now for some reason 2 colliding bulelts arn't always detected, 2/3 times they get destroyed, 1/3 they just continue.

    I just noticed that if I try hard enough I can even pass through walls:

    This is my collision matrix:

    The code that sees if any trigger has been made:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. /// <summary>
    5. /// Stef Geukens
    6. ///
    7. /// This code will determine if the object it is attached to has triggered a overlap with a collider object.
    8. /// If so, the object is destroyed. When the object hits another player then his own (set playernum to the correct player)
    9. /// then a function is called (Hurt) in the ShotPlayer script so thaty script knows when the score in the scorescript has
    10. /// to be updated and for what player.
    11. /// </summary>
    12.  
    13. public class BulletTriggerDetection : MonoBehaviour {
    14.     public static BulletTriggerDetection BTD;
    15.     public int playerNum = 1;
    16.     public bool destroyOnImpact = true;
    17.     public bool destroyOnTimer = true;
    18.     public bool destroyOnNumberOfCollides = false;
    19.     public int maxNumberOfCollides = 6;
    20.     private int numberOfCollides = 0;
    21.  
    22.     void Start()
    23.     {
    24.         BTD = gameObject.GetComponent<BulletTriggerDetection>(); ;
    25.     }
    26.  
    27.     void OnTriggerEnter2D(Collider2D  col)
    28.     {
    29.       Debug.Log(gameObject.name + " has collided with " + col.gameObject.name);
    30.       Debug.Log("My layer: " + gameObject.layer);
    31.       Debug.Log("Number of Impacts: " + numberOfCollides);
    32.  
    33.         if (playerNum == 1)
    34.         {
    35.        
    36.                 if (col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player3") || col.gameObject.tag == ("Player4"))
    37.                 {
    38.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    39.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    40.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    41.                 }
    42.                 else if (col.gameObject.tag != ("Player1") && destroyOnImpact)
    43.                 {
    44.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    45.                 }
    46.                 else if (col.gameObject.tag != ("Player1"))
    47.                 {
    48.                     numberOfCollides += 1;
    49.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    50.                 }
    51.  
    52.  
    53.         }
    54.         else if (playerNum == 2)
    55.         {
    56.  
    57.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player3") || col.gameObject.tag == ("Player4"))
    58.                 {
    59.                     Debug.Log("State1");
    60.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    61.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    62.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    63.                 }
    64.                 else if (col.gameObject.tag != ("Player2") && destroyOnImpact)
    65.                 {
    66.                     Debug.Log("State2");
    67.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    68.                 }
    69.                 else if (col.gameObject.tag != ("Player2"))
    70.                 {
    71.                     Debug.Log("State3");
    72.                     numberOfCollides += 1;
    73.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    74.                 }
    75.  
    76.         }
    77.         else if (playerNum == 3)
    78.         {
    79.  
    80.  
    81.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player4"))
    82.                 {
    83.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    84.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    85.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    86.                 }
    87.                 else if (col.gameObject.tag != ("Player3") && destroyOnImpact)
    88.                 {
    89.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    90.                 }
    91.                 else if (col.gameObject.tag != ("Player3"))
    92.                 {
    93.                     numberOfCollides += 1;
    94.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    95.                 }
    96.  
    97.         }
    98.         else if (playerNum == 4)
    99.         {
    100.  
    101.  
    102.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player3"))
    103.                 {
    104.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    105.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    106.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    107.                 }
    108.                 else if (col.gameObject.tag != ("Player4") && destroyOnImpact)
    109.                 {
    110.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    111.                 }
    112.                 else if (col.gameObject.tag != ("Player4"))
    113.                 {
    114.                     numberOfCollides += 1;
    115.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    116.                 }
    117.  
    118.       }
    119.     }
    120.  
    121.  
    122.     public static void destroyBullet(GameObject objectInNeedOfDestruction, float destroyTimer, bool hit, bool exDestroyOnTimer, bool exDestroyOnCollide)
    123.     {
    124.         Vector3 position = objectInNeedOfDestruction.transform.position;
    125.         Quaternion rotation = objectInNeedOfDestruction.transform.rotation;
    126.         if (BTD.destroyOnTimer && exDestroyOnTimer)
    127.         {
    128.             Destroy(objectInNeedOfDestruction, destroyTimer);
    129.             BTD.showBulletAnimation(position, rotation, hit);
    130.         }
    131.         else if (BTD.destroyOnNumberOfCollides && BTD.numberOfCollides >= BTD.maxNumberOfCollides)
    132.         {
    133.             Destroy(objectInNeedOfDestruction, 0);
    134.             BTD.showBulletAnimation(position, rotation, hit);
    135.         }
    136.     }
    137.  
    138.  
    139.     public Transform hitPrefab;
    140.     void showBulletAnimation(Vector3 position, Quaternion rotation, bool hit)
    141.     {
    142.         if (hit)
    143.         {
    144.             Transform hitParticleClone = Instantiate(hitPrefab, position, rotation) as Transform;
    145.             Destroy(hitParticleClone.gameObject, 2f);
    146.         }
    147.  
    148.     }
    149. }
    150.  
    gameobject settings (rigidbody is set to continues):

    ------------------------------
    The second type of bullet is a rubber ball, effected by gravity and it should bounce of objects and ground, and get destroyed by other bullets or hitting and killing a player.


    As you can see this parent has been set as a trigger as to be destroyed by a player or another bullet, the child has been set as collider:


    With very low speeds the rubber ball seems to work a bit beter but thats not what I want.


    Thanks for looking in to it!
     
    Last edited: May 4, 2016
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    You need to provide information on how you're moving the Rigidbody2D. Something is causing it to overlap other colliders which is typically because the position is being driven directly via the Transform or that Discrete collision-detection mode is being used on objects moving fast.
     
  3. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    Hi MelvMay, euhm it's code started from a tutorial from Brackeys, here's my move code:
    Code (CSharp):
    1.        public void Move(float move, bool crouch, bool jump, bool grab)
    2.         {
    3.             if (GetComponent<Rigidbody2D>().velocity.y < -maxFallSpeed)
    4.             {
    5.                 GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, -maxFallSpeed);
    6.             }
    7.  
    8.             //  Debug.Log("Grab: " + grab + " - Overlap: " + Physics2D.OverlapCircle(grabCheck.position, grabRadius, whatIsGround) + " - Grounded:" + grounded + " - Velocity: " + (GetComponent<Rigidbody2D>().velocity.y < wallSlideSpeedUpwardsDetection) + " - Times: " + (grabTimes < 1));
    9.             if (grab && Physics2D.OverlapCircle(grabCheck.position, grabRadius, whatIsGround) && !grounded && GetComponent<Rigidbody2D>().velocity.y < wallSlideSpeedUpwardsDetection && grabTimes < maxOneSideGrap)
    10.             {
    11.                 wallSliding = true;
    12.                 wallJumpAvailable = true; //so we can jump of the walls
    13.                 doubleJumpAvailable = false; //but we don't want another doublejump
    14.             }
    15.             else if (wallSliding == true)
    16.             {
    17.                 grabTimes += 1;
    18.  
    19.                 if (grabTimes > maxOneSideGrap - 1)
    20.                 {
    21.                     //Debug.Log("Grab: " + grabTimes);
    22.                     //ADD A WARNING ANIMATION HERE (is dit nodig?)
    23.                 }
    24.  
    25.                 wallSliding = false;
    26.             }
    27.             else if (!(GetComponent<Rigidbody2D>().velocity.y < wallSlideSpeedUpwardsDetection))
    28.             {
    29.                 wallSliding = false;
    30.                 wallJumpAvailable = false;
    31.             }
    32.  
    33.             if ( wallSliding == true)
    34.             {
    35.                 if (GetComponent<Rigidbody2D>().velocity.y < wallSlideSpeedUpwardsDetection)
    36.                  {
    37.                      GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, -wallSlideSpeedMax);
    38.                  }
    39.             else
    40.                 {
    41.  
    42.                 }
    43.             }
    44.  
    45.  
    46.             // If the character has a ceiling preventing them from standing up, keep them crouching
    47.             if (Physics2D.OverlapCircle(ceilingCheck.position, ceilingRadius, whatIsGround) && grounded)
    48.                 crouch = true;
    49.  
    50.             // If crouching, check to see if the character can stand up
    51.             if (!crouch && anim.GetBool("Crouch"))
    52.             {
    53.                 // If the character has a ceiling preventing them from standing up, keep them crouching
    54.                 if (Physics2D.OverlapCircle(ceilingCheck.position, ceilingRadius, whatIsGround))
    55.                     crouch = true;
    56.             }
    57.  
    58.             // Set whether or not the character is crouching in the animator
    59.             anim.SetBool("Crouch", crouch);
    60.  
    61.             if (grounded)
    62.             {  
    63.                 //when grounded again,reset grabTimes
    64.                 grabTimes = 0;
    65.             }  
    66.  
    67.             //only control the player if grounded or airControl is turned on
    68.             if (grounded || airControl)
    69.             {
    70.                 // Reduce the speed if crouching by the crouchSpeed multiplier
    71.                 move = (crouch ? move*crouchSpeed : move);
    72.  
    73.                 // The Speed animator parameter is set to the absolute value of the horizontal input.
    74.                 anim.SetFloat("Speed", Mathf.Abs(move));
    75.  
    76.                 // Move the character
    77.                 GetComponent<Rigidbody2D>().velocity = new Vector2(move*maxSpeed, GetComponent<Rigidbody2D>().velocity.y);
    78.  
    79.                 // If the input is moving the player right and the player is facing left...
    80.                 if (move > 0 && !facingRight)
    81.                 {
    82.                     // ... flip the player.
    83.                     Flip();
    84.                     grabTimes = 0; //reset grabtimes so you can walljump from side to side
    85.                     Debug.Log("Grab: " + grabTimes);
    86.                 }
    87.                 // Otherwise if the input is moving the player left and the player is facing right...
    88.                 else if (move < 0 && facingRight)
    89.                 {
    90.                     // ... flip the player.
    91.                     Flip();
    92.                     grabTimes = 0; //reset grabtimes so you can walljump from side to side
    93.                     Debug.Log("Grab: " + grabTimes);
    94.                 }
    95.             }
    96.             // If the player should jump...
    97.             if (jump)
    98.             {
    99.                 if (grounded && anim.GetBool("Ground"))
    100.                 {
    101.                     // Add a vertical force to the player.
    102.                     grounded = false;
    103.                     anim.SetBool("Ground", false);
    104.                     doubleJumpAvailable = true;
    105.                     wallJumpAvailable = false;
    106.                     GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
    107.                     GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, jumpForce));
    108.                 }
    109.                 else if (doubleJumpAvailable)
    110.                 {
    111.                     // Add a vertical force to the player. But less strong then starting from ground
    112.                     grounded = false;
    113.                     anim.SetBool("Ground", false);
    114.                     doubleJumpAvailable = false;
    115.                     wallJumpAvailable = false;
    116.                     GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
    117.                     GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, (jumpForceModifierDoubleJump * jumpForce)));
    118.                 }
    119.                 else if (wallJumpAvailable)
    120.                 {
    121.                     // Add a vertical force to the player. But less strong then starting from ground
    122.                     grounded = false;
    123.                     anim.SetBool("Ground", false);
    124.                     wallJumpAvailable = false;
    125.                     GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
    126.                     GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, (jumpForceModifierWallJump * jumpForce)));
    127.                 }
    128.             }
    129.         }
    Thanks
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    From what you've posted, it seems you're only moving via velocity/forces. If you are getting overlaps then it'll be because you're using Discrete collision detection mode. Try setting Continuous on the Rigidbody2D component.

    Know that a PolygonCollider2D isn't a single collider; it's just a way to turn a (potentially) concave outline into multiple convex polygons. Box2D will only solve overlaps to each convex polygon individually so the solution doesn't always move it away from the outline itself. This is why using continous mode is important as it can stop overlaps in the first place.
     
    Last edited: May 3, 2016
  5. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    Solved, thank you very much for your help!
     
    MelvMay likes this.
  6. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    MelvMay, it seems my problem is re-occuring with my bullets.

    I have 2 types of bullets and the problems are I think simular in solution but the effect is somewhat different.

    My first bullet type is a fireball, it just moves in straight lines, when colliding with a player it is destroyed unless it's the player who fired the bullet, if it collides with another bullet or object or ground it should be destroyed aswel.
    Now for some reason 2 colliding bulelts arn't always detected, 2/3 times they get destroyed, 1/3 they just continue.

    I just noticed that if I try hard enough I can even pass through walls:

    This is my collision matrix:

    The code that sees if any trigger has been made:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. /// <summary>
    5. /// Stef Geukens
    6. ///
    7. /// This code will determine if the object it is attached to has triggered a overlap with a collider object.
    8. /// If so, the object is destroyed. When the object hits another player then his own (set playernum to the correct player)
    9. /// then a function is called (Hurt) in the ShotPlayer script so thaty script knows when the score in the scorescript has
    10. /// to be updated and for what player.
    11. /// </summary>
    12.  
    13. public class BulletTriggerDetection : MonoBehaviour {
    14.     public static BulletTriggerDetection BTD;
    15.     public int playerNum = 1;
    16.     public bool destroyOnImpact = true;
    17.     public bool destroyOnTimer = true;
    18.     public bool destroyOnNumberOfCollides = false;
    19.     public int maxNumberOfCollides = 6;
    20.     private int numberOfCollides = 0;
    21.  
    22.     void Start()
    23.     {
    24.         BTD = gameObject.GetComponent<BulletTriggerDetection>(); ;
    25.     }
    26.  
    27.     void OnTriggerEnter2D(Collider2D  col)
    28.     {
    29.       Debug.Log(gameObject.name + " has collided with " + col.gameObject.name);
    30.       Debug.Log("My layer: " + gameObject.layer);
    31.       Debug.Log("Number of Impacts: " + numberOfCollides);
    32.  
    33.         if (playerNum == 1)
    34.         {
    35.        
    36.                 if (col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player3") || col.gameObject.tag == ("Player4"))
    37.                 {
    38.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    39.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    40.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    41.                 }
    42.                 else if (col.gameObject.tag != ("Player1") && destroyOnImpact)
    43.                 {
    44.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    45.                 }
    46.                 else if (col.gameObject.tag != ("Player1"))
    47.                 {
    48.                     numberOfCollides += 1;
    49.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    50.                 }
    51.  
    52.  
    53.         }
    54.         else if (playerNum == 2)
    55.         {
    56.  
    57.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player3") || col.gameObject.tag == ("Player4"))
    58.                 {
    59.                     Debug.Log("State1");
    60.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    61.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    62.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    63.                 }
    64.                 else if (col.gameObject.tag != ("Player2") && destroyOnImpact)
    65.                 {
    66.                     Debug.Log("State2");
    67.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    68.                 }
    69.                 else if (col.gameObject.tag != ("Player2"))
    70.                 {
    71.                     Debug.Log("State3");
    72.                     numberOfCollides += 1;
    73.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    74.                 }
    75.  
    76.         }
    77.         else if (playerNum == 3)
    78.         {
    79.  
    80.  
    81.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player4"))
    82.                 {
    83.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    84.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    85.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    86.                 }
    87.                 else if (col.gameObject.tag != ("Player3") && destroyOnImpact)
    88.                 {
    89.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    90.                 }
    91.                 else if (col.gameObject.tag != ("Player3"))
    92.                 {
    93.                     numberOfCollides += 1;
    94.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    95.                 }
    96.  
    97.         }
    98.         else if (playerNum == 4)
    99.         {
    100.  
    101.  
    102.                 if (col.gameObject.tag == ("Player1") || col.gameObject.tag == ("Player2") || col.gameObject.tag == ("Player3"))
    103.                 {
    104.                     col.gameObject.GetComponent<ShotPlayer>().Hurt(col.gameObject.tag, playerNum);
    105.                     // Debug.Log("Player" + playerNum + " just shot " + col.gameObject.tag);
    106.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    107.                 }
    108.                 else if (col.gameObject.tag != ("Player4") && destroyOnImpact)
    109.                 {
    110.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    111.                 }
    112.                 else if (col.gameObject.tag != ("Player4"))
    113.                 {
    114.                     numberOfCollides += 1;
    115.                     destroyBullet(gameObject, 0, true, destroyOnTimer, destroyOnNumberOfCollides);
    116.                 }
    117.  
    118.       }
    119.     }
    120.  
    121.  
    122.     public static void destroyBullet(GameObject objectInNeedOfDestruction, float destroyTimer, bool hit, bool exDestroyOnTimer, bool exDestroyOnCollide)
    123.     {
    124.         Vector3 position = objectInNeedOfDestruction.transform.position;
    125.         Quaternion rotation = objectInNeedOfDestruction.transform.rotation;
    126.         if (BTD.destroyOnTimer && exDestroyOnTimer)
    127.         {
    128.             Destroy(objectInNeedOfDestruction, destroyTimer);
    129.             BTD.showBulletAnimation(position, rotation, hit);
    130.         }
    131.         else if (BTD.destroyOnNumberOfCollides && BTD.numberOfCollides >= BTD.maxNumberOfCollides)
    132.         {
    133.             Destroy(objectInNeedOfDestruction, 0);
    134.             BTD.showBulletAnimation(position, rotation, hit);
    135.         }
    136.     }
    137.  
    138.  
    139.     public Transform hitPrefab;
    140.     void showBulletAnimation(Vector3 position, Quaternion rotation, bool hit)
    141.     {
    142.         if (hit)
    143.         {
    144.             Transform hitParticleClone = Instantiate(hitPrefab, position, rotation) as Transform;
    145.             Destroy(hitParticleClone.gameObject, 2f);
    146.         }
    147.  
    148.     }
    149. }
    150.  
    gameobject settings (rigidbody is set to continues):

    ------------------------------
    The second type of bullet is a rubber ball, effected by gravity and it should bounce of objects and ground, and get destroyed by other bullets or hitting and killing a player.


    As you can see this parent has been set as a trigger as to be destroyed by a player or another bullet, the child has been set as collider:


    With very low speeds the rubber ball seems to work a bit beter but thats not what I want.


    Thanks for looking in to it!
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Continuous won't make any difference if it's a trigger. You can completely tunnel through a trigger if the colliders are moving fast enough. Continuous only works when contacting non-triggers because it stops the collider at the point of contact whereas with triggers, this obviously isn't the case.

    All I can say is that Box2D has extremely robust continuous detection but this requires non-triggers. I can only presume as well that because you're using Kinematic bodies, you're moving them with forces/MovePosition. Also note that Kinematic won't collide with Static colliders (the level colliders) and will only work as triggers which again, don't work with continuous.
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    BTW: For this reason, fast-moving objects that need to touch triggers tend to use raycasts.
     
  9. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    Still not sure how I can fix it. I will look in to the raycasts, thanks for the help!
     
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    If you can create a simple reproduction case that I could download then I wouldn't mind taking a look at it.
     
  11. Xercium

    Xercium

    Joined:
    Sep 13, 2014
    Posts:
    22
    Simple is ussually hard for me hehe. Thank you, I'm gonna try to fix it with raycasts like you said, if it doesn't work out I will create a simple projectfile that you could look at.

    Thanks allot!
     
  12. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Hey sorry to revive an old thread, but is there any way this information could be added to the documentation? The only mention of CCD in the manual is in the 3D physics section, and it has no mention of the impact on triggers. Some clarity here would have been very helpful. https://docs.unity3d.com/Manual/ContinuousCollisionDetection.html
     
    MelvMay likes this.
  13. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    FYI: Work has begun on completely redoing the 2D physics manual so this will definately be content in the Rigidbody2D section. It'll also be completely independent of the 3D physics content.
     
  14. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    That's great to hear. I was quite confused that the manual says that 2D is just "flattened" 3D, but I had understood that the 2D physics engine was a port of Box2D. Hopefully this will be clarified too. It's one of those things where detailed, authoritative information is essential.

    Thanks for the response. :)
     
  15. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Honestly, the manuals all over the place have these kinds of statements which are designed to help think about how something works conceptually but some take it literally to mean implementation which of course it isn't.
     
  16. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Yeah, I figured that was the case, but when you're looking for what's going on in the physics system (which is essentially a black box) these vague high level statements end up being all you have to go on. In any case I'm happy that it's getting some love. Hopefully it will demystify some of these concepts for more experienced users and be a bit more thoughtful and specific in its use of language.

    For what it's worth that CCD page is actually an awesome explanation for 3D.