Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

when Rigidbody.isKinematic = true, can we get the wanted direction during overlapping ?

Discussion in 'Physics' started by canis, Jan 14, 2019.

  1. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    65
    Assume they both have collider, and able to contact each other in "layer collision matrix" setting
    I want to find out if my character overlapping something, and get the suggested direction vector from physic engine. during the Rigidbody.isKinematic = true;

    the first condition is rigidbody mush stay in Kinematic state. (can't let physic engine take control)
    in fact, I want to remove rigidbody as well. if anyone can point me the way to only use collider to find the possible direction vector will be better :)

    can't find it on google may be I missing the keyword. so any help are welcome.
    PS: I understand that may need to calculate bunk of Vector & Quaternion stuff, I should understand the basic.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,572
    I think Physics.ComputePenetration is what you're looking for. It doesn't even require a Rigidbody, just the colliders.

    Also, you may get the OnCollision events with your kinematic rigidbody by configuring "Contact Pairs Mode" in the Physics options.
     
    canis likes this.
  3. canis

    canis

    Joined:
    Oct 25, 2013
    Posts:
    65
    Thanks @Edy I will test it out, seem like it's what I need