Hello! I’ve been looking for a tool to make foot placement on Mecanim for a while now…
I couldn’t find anything, from simple to complex solutions, so I had to come up with my own thing (this is at the simple side of the rainbow):
This basic functionality is what you see on most games, just a simple raycast based approach instead of going crazy on detailed placement.
I mean, this is nowhere near Rune’s Locomotion system, but may be of some use for your retargeted Mecanim characters.
So I was wondering if anybody else would need this. Note that this tool is based on Mecanim IKs, so it is Unity Pro only.
Why use this?:
º Works with Mecanim.
º Works on any retargeted animation.
How it works:
Judging by the fact that every Mecanim character requires an Agent/Controller script I decided to make this a extension for the Animator class instead of attaching one more MonoBehaviour or forcing the need to change too much code on every controller script.
Once you have the class imported, every Animator instance you have gives you the option to use the FootPlacement() method inside of your controller script; Ideal results comes from using this inside of OnAnimatorIK().
For basic heel placement all you need is to tell the function who the pelvis is and decide on IK weights and foot offset for fine adjustment.
For detailed foot aligment, adding a empty GameObject on each foot is required because a reference for Raycasts is needed in world space instead of joint’s local space.
So, a controller using this function with normal aligment would be like this:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Animator))]
public class MyController : MonoBehaviour {
public bool Do; // If need to turn off placement for any reason.
public float HeelOffset; // Fine adjustment of heels.
public float FeetOffset; // Fine adjustment of feet.
public Transform Hips; // The Pelvis joint, just a height reference.
public Transform LeftToe; // Foot joint used as foot length reference.
public Transform RightToe; // Foot joint used as foot length reference.
public Transform LeftTip; // Empty GameObject, Joints' world space reference.
public Transform RightTip; // Empty GameObject, Joints' world space reference.
private Animator Actor; // The Animator component attached.
//
void Start() {
Actor = GetComponent<Animator>();
}
//
void OnAnimatorIK(int Layer) {
Actor.FootPlacement(Do,HeelOffset,FeetOffset,(Actor.GetFloat("Speed")/10),Hips,LeftToe,RightToe,LeftTip,RightTip);
}
}
… And the extension class will try its best to do the hard work.
I did this thing in few hours and I think is not very hard to replicate it; Also, is Unity pro only so I don’t know if anybody would be interested on this class. If you are interested just let me know, I may upload it for free or a very low symbolic price, dunno.
The code is a open C# class as well, so you can modify/extend it for your particular needs.
[Help Files]
You can download the ‘Guide’ PDF from here: http://www.bedroomdeveloper.com/guides/mfp.pdf