Hey guys,
so I’m trying to make a smooth transition between my running and walking animation. Here’s what I’ve got.
if (Input.GetButton ("Fire1")) {
anim.SetBool ("moving", true);
float blendTime = 0;
blendTime = Mathf.Lerp (0f, 1f, Time.time);
anim.SetFloat ("Blend", blendTime);
transform.Translate (Input.GetAxis ("Horizontal") * walkSpeed * sprintMultiplier * Time.deltaTime, 0f, Input.GetAxis ("Vertical") * walkSpeed * sprintMultiplier * Time.deltaTime, Space.World);
} else {
anim.SetBool ("moving", true);
float blendTime = 1;
blendTime = Mathf.Lerp (1f, 0f, Time.time);
anim.SetFloat ("Blend", blendTime);
transform.Translate (Input.GetAxis ("Horizontal") * walkSpeed * Time.deltaTime, 0f, Input.GetAxis ("Vertical") * walkSpeed * Time.deltaTime, Space.World);
}
Somehow it doesn’t work and snaps between changing animations. Why?