Search Unity

Is there any way for CapsuleCast to return multiple contacts per object?

Discussion in 'Physics' started by Babooh, Jun 24, 2022.

  1. Babooh

    Babooh

    Joined:
    Jul 26, 2019
    Posts:
    10
    I'm implementing collision for my character controller and the method I use is described here at slide 59. Simplified, you capsule sweep, store all contacts found and treat them as plane constraints, and lastly solve all constraints using some solver.

    This method works great, but for concave mesh colliders it completely breaks apart. This is not because of the method itself, but because of the fact that unity's CapsuleCastAll only returns a single contact point per object. For a convex object you only need one constraint to make sure the character doesn't go through it, but for a concave object multiple constraints could be needed depending on its shape.

    Is there is a way to get CapsuleCastAll to return multiple contacts per object? If not, what would be a suitable solution? Write my own sweep algorithm or use a different method of (continuous) collision detection?
     
    Last edited: Jun 25, 2022
  2. MaxHerrmann

    MaxHerrmann

    Joined:
    Mar 11, 2020
    Posts:
    34
    Isnt CapsuleCastAll returning an RaycastHit array?
     
  3. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    446
    I think the normal which is returned by CapsuleCast is the normal representing the collision plane which you can use for your solver (it is not the surface normal). You probably don't need CapsuleCastAll at all I guess.