- Home /
Question by
cwinder_hothead · Mar 27, 2014 at 03:39 AM ·
animationmecanimvelocity
How do I access the "Average Velocity" of a run animation?
Im trying an approach to a problem which lets the movement animations control the root motion of my character to minimize foot sliding and I would like to access the "Average Velocity" parameter listed so that I can effectively vary the speed of the animation which predictable results for velocity.
Comment
Answer by Damien-Delmarle · Mar 27, 2014 at 04:57 AM
i think i have same problem i used to calcul a fake velocity from transform but its wrong if the character rotate:
float speed =0F;
float lastSpeed = 0f;
float strafe = 0f;
float lastStrafe = 0f;
Vector3 direction = Vector3.zero;
void MecanimLocomotion()
{
speed = (lastSpeed - transform.position.x)/Time.deltaTime;
strafe = (lastStrafe - transform.position.z)/Time.deltaTime;
direction = transform.rotation * new Vector3(speed,0,strafe);
Debug.Log (direction.normalized +" //// "+direction.magnitude);
//set values at the end
lastSpeed = transform.position.x;
lastStrafe = transform.position.z;
}
Your answer
Follow this Question
Related Questions
Mecanim additive animation sends characters flying? 1 Answer
AddMixingTransform with Mecanim 1 Answer
Add more bones to skeleton - vertebraes definition...? 0 Answers
How to create a 2D rig? 1 Answer
Multiple Animation Events not firing 1 Answer