Search Unity

Humanoid player model and physics

Discussion in 'Physics' started by XJonOneX, Jan 13, 2018.

  1. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    114
    Ok guys, I am at a complete loss of what to do. I've done hours of Google searching and I'm usually not one to stub my toe and go to the nearest hospital demanding a team of specialists. ;) I've gotten a model from Mixamo and some animations, set up a test project, got all my animations imported, animator controller set up and verified the animations. All of that is picture perfect. I even have a huge quad for a walking surface! :D

    (I've gone through the Roll-A-Ball and Space Shooter tutorials. I wanted to give some ideas a go and decided against the spooky zombie teddy shooter tutorial.)

    My problem is having my player object do any kind of moving or collision. (Scripting is not an issue) I've tried colliders of the box and capsule variety surrounding the model, but any time I apply a velocity or force or something physics related happens (I'm dropping it in the scene above the quad) my player object does not remain upright and falls over like a pillar. o_O I've tweaked mass and force scalar variables to no avail.

    Could this falling over be due to the fact that the model... origin (?) is not in the center of the model (I'd say the hips would be center) but rather the origin is at the soles of the feet? The transform position when set to 0/0/0 puts the feet there, perfectly on top of my quad which is also at 0/0/0. I had to re-center the box and capsule collider from 0/0/0 to a little higher on the Y-axis. It looks like there's some sort of center of gravity thing going on but it's not set properly.

    I decided to try a Mesh Collider, but Unity gives me this little gem:

    Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5. (FYI I'm using 2017.3.0f3) If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy ... non-important bits

    In the long run, I want to be able to detect certain parts of the body for damage effect purposes, and for some special effects via code. But forget all that if I can't even get the darn thing moving properly! :eek:

    The character controller is out of the question. It's a glorified capsule collider with gimped physics interactions imho. :p I want the player object to be affected by anything and everything physics related, from bullet impacts to explosions. Eventually I want to code in some IK for arm movements, but that's waaaaay later in the game. :D

    Oh, while we're on the topic of physics, what unit of measurement is velocity in? Meters per second?

    Thank you all for any help. I'm so eager to code with Unity, and Mixamo just made my life a whole lot easier to prototype ideas. :cool:
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,537
    Models have nothing to do with physics, just colliders. It is, of course, going to fall over if you apply any forces to a capsule because it's a capsule, with a round bottom. Use the rigidbody constraints to keep it from rotating on x and z.

    Mesh colliders should be used very sparingly. Most games build composite/compound colliders out of smaller capsule, sphere and box colliders. By attaching those colliders to bones, they allow arcuate hit registration on limbs, or whatever, as they'll follow animations.

    Most games are also smoke and mirrors. That glorified capsule colliders character controller is probably more advanced than a lot of games you have played, but good design and implementation hid that from you.

    If you want really complex physics characters then check out Puppetmaster on the asset store. Doing that sort of thing is a pretty modern development.
     
  3. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    114
    Atm I have a box collider and it tips over also when a force is applied. :( I missed the constraints, looks like a possible solution.

    I was wondering if I could do mesh specific colliders. I'll have to read up on these compound colliders. Thanks!

    The character controller description didn't really excite me with it's lack of rigidbody interactions and whatnot. I'm all for coding smoke and mirrors (I did it for a decade with an engine from 1996) but what gets me revved up are the possibilities that come baked into Unity. :D
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I always put a capsule collider on my characters, and it's perfectly good. :) Just my 2 cents. heh.
     
  5. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    114
    The constraints on the X and Z helped it from tipping over. I'm experimenting around with the character controller. The lack of a rigidbody is a little cumbersome, but I'm warrming up to the idea of coding player physics by hand. Still gotta fool around with compound colliders, but I'm really getting a good understanding of all this. :)