Procedural character animation: Soccer

Tech demo of player running, dribbling, kicking, juggling, and walking:

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.

3 Likes

5288121--530496--Screen Shot 2019-12-16 at 11.04.18 AM.png

whoa, that’s pretty tight.

Sharp cuts with ball demo.

2 Likes

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)

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!

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.

1 Like

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().

1 Like

Triangle passing.

3 Likes

Catch up with moving ball, step on ball, reverse direction.

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?

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.

Sorry for my late reply.

That makes sense. Thanks for the tip!

Arbitrary pass receiver selection using mouse:

2 Likes

I’m confused, where’s the asset store link lol

Hi very impressive work, did you implement a Goalkeeper AI?. look forward to see more of this project.

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