I am working on some foot placement and so far have my characters feet aligning to the ground nicely, however the code snipet I rely on to do this:
Quaternion footRotation = Quaternion.LookRotation( Vector3.Exclude( hit.normal, transform.forward ), hit.normal );
forces the foot to always face the same direction as the transform. What I’d like to do here is to have the foot point in the direction it normally would before applying IK rotation weight.
Seems like that would require “transform.forward” in the above snipet to change, but i’m unsure of what to use. If i grab the bone transform for the foot and use its forward, things go all wrong :). Also tried some Vector3.Cross calls with the foot up and transform forward, etc… some combinations come close but still fail.
Just for a visual on what happens with this code so far, here are two SS’s:
- Without IK (natural foot rotation at idle): http://screencast.com/t/N5ZVh5NSzzPu
- With IK (facing transform forward): http://screencast.com/t/2obcpS7VD
I’d like to have the Vector3.Exclude working so that the foot is planted using IK as in (2) above, but uses the animations foot rotation (on the yaxis?) as in (1).
Can someone with some strong math skills help me out here :)?