Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Collision point

Discussion in 'Project Tiny' started by Sladzio, Mar 17, 2019.

  1. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    Hey! Is there a way to retrieve a contact point of the collision between two BoxCollider2D?
     
  2. Zoelovezle

    Zoelovezle

    Joined:
    Aug 7, 2015
    Posts:
    54
    Add BoxCollider & Rigidbody2D to both entities. Done :)
     
  3. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    This part I know. I am searching for a function which could retrieve the point (Vector3) of the collision.
     
  4. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
  5. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    These unfortunately return only array of entities. I have seen that hitbox2dservice contains a method for getting detailed info about overlapping but I can't get it to work. It returns values near Vector (0,0).Another option could be to use raycasting but I wanted particularly to use CircleCollider.
     
    Zoelovezle likes this.
  6. Zoelovezle

    Zoelovezle

    Joined:
    Aug 7, 2015
    Posts:
    54
    This is what you need ut.HitBox2D.HitBox2DService.detailedOverlapInformation(), this will basically return you vertices of a polygon made out from the intersection. Polygon would be a particular case once they are intersecting, thus making more than 1 contact point.
     
  7. Zoelovezle

    Zoelovezle

    Joined:
    Aug 7, 2015
    Posts:
    54
    The contact point between 2 Circle collider or 2 Box collider?
     
  8. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    I have one object which has a circle collider and the other object has a box collider. When they collide I need to retrieve the contact point. Maybe I will try one more time with the hotbox2d but the problem there is that there isn't any circle hit box