Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How does the Unity Standard Asset Third Person Character Controller work?

Discussion in 'Scripting' started by JetStreamSham, Nov 5, 2017.

  1. JetStreamSham

    JetStreamSham

    Joined:
    Jul 4, 2015
    Posts:
    27
    I've been looking at the Unity Standard Asset Third Person Character Controller scripts, and I can't seem to figure out how it moves the player. Does it drive the character with animations or is the rigid body's velocity controlled with scripts or is it something else entirely?
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I believe it's a bit of both. The main movement is root motion. That is, after the input from the player is taken into account. It also disables root motion when in air and/or jumping, iirc. :)
     
  3. JetStreamSham

    JetStreamSham

    Joined:
    Jul 4, 2015
    Posts:
    27
    So if I wanted to increase the distance covered during running I would modify the running animation to move further away from the root or if I wanted a more precise turn than a quarter turn I would make an animation that turns the player a little than that?
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Sounds logical. Your rotation comment reminded me of something. For some of the turning, there is root motion plus some added code, which you can toggle , I believe. You probably noticed that if you looked at it.
     
  5. JetStreamSham

    JetStreamSham

    Joined:
    Jul 4, 2015
    Posts:
    27
    Is using root motion to drive the player a good way to do control the player? Do you know of any downside to controlling the character this way?
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I do not have enough experience to really say. I've seen some arguments in both directions, with a little internet searching.
    When I first started using Unity, the root motion confused me. It seemed cool, but I re-wrote the code to not use it :)
    I don't really know if people use it more or not, or if it's better or not.. sorry :)
    I can say it does seem to work pretty well with the standard asset 3rd character, though. So, I guess it's really up to you and how you feel about it.
     
  7. JetStreamSham

    JetStreamSham

    Joined:
    Jul 4, 2015
    Posts:
    27
    Alright, thank you for your help.:) I think I'm gonna give moving the character with root motion a go.:)
     
  8. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    In my personal experience using root motion will take away a lot of control from you (too much).
    You either have to adjust your animation, or you need to increase its playback speed, and often you don't want to do either (changing an animation just to make the character move faster takes a relatively long time).

    In order to get good animation results (controllable, no foot slipping, controllable playback speed), I don't use root motion, and to get foot-placement without slipping I use an IK script that plants the feet on the ground and holds them at the right position until they are lifted again.

    The end result is a really smooth walking cycle with no foot slipping at all, and a way to easily control character speed.
     
  9. JetStreamSham

    JetStreamSham

    Joined:
    Jul 4, 2015
    Posts:
    27
    I'm not sure I understand. If you don't use root motion from an animation, how do you control your character?
     
  10. ElFab

    ElFab

    Joined:
    Sep 20, 2017
    Posts:
    37
    There is a lot's of way of making move an avatar in third person view, for exemple :
    - you make move player using naveMeshAgent and then do that animations try to snap the move.
    - You make move the player with use of forces, and then do that animations try to snap the move.
    - You calculate where player should go and then manipulate anims for make move your player
    - ... etc there is a lot's of way.

    The first think you have to do is to choose how you'll do your movement.
    There is easy way and difficult way but you have lot's of choice.
    Choices depend of how your game is disign, point and click or direct controle of movement?
    For my current point and click game, i use navemeshagent for calculate trajectories and then calculate input for animator for make move my player, that's not easy but have a nice look, so in this case i do use root motion because it's what make move my player^^.
    But if you're not usual and are in a pointer-click way i think your best choice is to unactivate root motions yes and take a look at this tutorial (the player part): https://unity3d.com/fr/learn/tutorials/projects/adventure-game-tutorial

    If you are in a direct control configuration there is nothing to do, just use standard asset, settup your avatar and it's all, that use root motion and is nice. If you need help you'll have some ;).