Search Unity

Games Procedural character animation: Soccer

Discussion in 'Projects In Progress' started by tigger, Dec 16, 2019.

  1. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Tech demo of player running, dribbling, kicking, juggling, and walking:
    https://www.youtube.com/channel/UC-IwHrIeNgjbzYWFhQYNvxw

    Character animation is 100% procedural. No imported keyframed animations used.

    Goal of project
    - Player movement defined and controlled entirely in code.
    - Precise player movement, especially foot placement / planting without "sliding" and "skating."
    - Variable-length strides while running and walking (accelerate, stutter steps, etc).
    - Ability to interact with other objects (e.g., soccer ball) at runtime.

    Project makes use of Unity's IK system (e.g., OnAnimatorIK) and bones system.




     
    Last edited: Nov 22, 2020
    AfterAll14, eaque and CityGen3D like this.
  2. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
  3. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    whoa, that's pretty tight.
     
  4. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Sharp cuts with ball demo.
     
    Jmonroe and dibdab like this.
  5. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    the system can be used along w rootmotionanimator control, right? can it be mixed w rootM animations? switching animator runtime can be done, i?

    you say IK is used, so already there's an animator. does it execute in lateupdate, or custom? (could be there a hack if controller could switch update/lateupdate)
     
    Last edited: Jan 23, 2020
  6. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Incredible! Would you be willing to share a bit how you do this, e.g.move IK effectors to make limbs etc move via script? Very cool!
     
  7. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    The intent is for character movement to be controlled at any given point in time by either the procedural/IK-based system or a conventional, imported animation with blending at runtime as you transition from one system to the other.

    The procedural system does make use of UnityEngine.Animator as that is what enables all the IK stuff (e.g., receiving OnAnimatorIK(int layerIndex). As it turns out, it also makes use of LateUpdate() for controlling spine and arm rotation.

    Hope that makes sense.
     
    tmonestudio likes this.
  8. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Yes. There are classes (Effectors or "Affectors") for positioning and rotation of extremities (feet). There are corresponding effectors that control body position and rotation. The trick is to keep those two things (e.g., body and feet) in sync, to be able to position the feet wrt the body, and to have parameterization to allow variable speeds, stride lengths, exact foot "plant" points, body pitch (during acceleration), body roll, etc.

    Basically, everything is done either within OnAnimatorIK() or LateUpdate().
     
    khos likes this.
  9. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Triangle passing.
     
    Jmonroe, dibdab and khos like this.
  10. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Catch up with moving ball, step on ball, reverse direction.
     
  11. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    38
    Hi Tigger,
    This is something I'm trying to learn to implement into my game. Do you think it could be done with Unity's Animation Rigging preview package? Also, how did you procedurally animate the running so it looks like the character has momentum and does not look robotic?
     
  12. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    I looked briefly at the Animation Rigging Preview documentation. I'm sure there's stuff in there that would be useful (e.g., constraints) but I didn't see anything that would replace code I'd already written. When it's GA I'll have to take another look.

    As far as momentum goes, when running at least, I guess the key is to make sure the character continues to move downwards a bit after the leading foot plants, then springs upward at the start of the next stride. The spine "rocking" slightly forward/backward helps as well.
     
  13. Nsingh13

    Nsingh13

    Joined:
    Dec 17, 2014
    Posts:
    38
    Sorry for my late reply.

    That makes sense. Thanks for the tip!
     
  14. tigger

    tigger

    Joined:
    Jan 8, 2013
    Posts:
    95
    Arbitrary pass receiver selection using mouse:

     
    gamefish and bobadi like this.
  15. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    I'm confused, where's the asset store link lol
     
  16. carored

    carored

    Joined:
    Mar 21, 2018
    Posts:
    11
    Hi very impressive work, did you implement a Goalkeeper AI?. look forward to see more of this project.
     
  17. Deleted User

    Deleted User

    Guest

    he will not give the football game for free on the asset store how do you think so. if he will then thanks to him a lot