I have made an animation inside unity for my gun theres two animations 1 that aims in and one that aims out I have wrote a simple script that triggers them if the RMB has either been pressed down or up. I was hoping it would make my gun aim down its sights when the RMB has been clicked and when let go of plays an animation back to its starting position. This does not work instead my gun sort of jerks into the aim down sights position and then changes back before I have let go of the RMB. How would I change my script (or animations) so that my gun plays an aim down sights animation and stops where it finishes before I let go of the RMB which plays the animation back to its original place?
Script
function Start () {
animation.wrapMode = WrapMode.Once;
}
function Update () {
if(Input.GetButtonDown(“Fire2”)){
animation.Play(“aim down sights”);
}
if(Input.GetButtonUp(“Fire2”)){
animation.Play(“aim down sights2”);
}
}