My question is simple I want to play animation and change the position of gun till the shift key remain pressed and when I leave the shift key the animation stop and then the gun come back to its original position. I am noob and I am learning c# intermediate.
I hope u understand. I tried following code but it`s not working.enter code here
public float animSpeed = 10; // Transition speed between running and walking animations.
public AnimationClip run;
public Vector3 runningPos; // Weapon position when running.
public Vector3 runningRot; // Weapon rotation when running.
void Update () {
if (Input.GetKeyDown (KeyCode.RightShift)) {
weaponAnimations.Stop ();
isRunning = true;
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.Euler(runningRot), animSpeed * Time.deltaTime);
transform.localPosition = Vector3.Lerp(transform.localPosition, runningPos, animSpeed * Time.deltaTime);
weaponAnimations.CrossFade (run.name);
}
}
Thnaksa in advance!