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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Looking for Docs on SimplexSolver and SurfaceInfoConstraints

Discussion in 'Physics Previews' started by scarface117, Mar 25, 2021.

  1. scarface117

    scarface117

    Joined:
    Nov 9, 2019
    Posts:
    16
    Hi, is there any information available about how to properly use SimplexSolver with SurfaceInfoConstraints?
    I'm trying to get my character to have a constraint on the floor and elements where it collides, so it affects it's velocity but I'm having a lot of trouble understanding what SimplexSolver is doing in the background, I have no idea if I'm setting the constraints properly because the results are always random.

    Does anyone know if there are docs about it, or would like to help me to start a thread for that and help other folks in the future?


    Thanks in advance!
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    I don't think there is at the moment. However, you can look at CharacterControllerUtilities.cs in the samples project, it shows the usage of SimplexSolver and how it interprets data. Also, you can just go ahead and ask any concrete questions you have, I'd be happy to answer.

    In short, when you do a query, you get some hits. Those hits need to be converted to SurfaceConstraintInfo for solver to work on. Plane being the surface normal, Velocity being the speed of the surface (if not static) and HitPosition being the closest point. RigidBodyIndex and ColliderKey represent the body that was hit. Priority is 1 for dynamic bodies, 0 for static. Touched holds the info on whether that constraint has been solved in the last solver call. The rest is internal info.
     
    scarface117 likes this.
  3. scarface117

    scarface117

    Joined:
    Nov 9, 2019
    Posts:
    16
    Thanks! This is helpful!
    One more question, what does the 'up' argument represent in the SimplexSolver.Solve method? Is it the up vector for the collider? (In my case, a capsule).
    Thanks!
     
    Last edited: Mar 26, 2021
    petarmHavok likes this.
  4. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    It's a normalized vector that points upwards, usually (0,1,0) or (0,0,1), opposite from gravity. It's used for detecting if character is sliding downwards or calculating if a slope is too steep for character to climb, for example.
     
    petarmHavok likes this.