- Home /
Animation Opposite
Hi to all, How the animation can return to the original position? (start position) which code should I use?
Sorry for my english, Paolo
Comment
First things first, check out the Animation Reference. Do some homework there, then come back if you still need help.
I had seen there, but I did not find anything.. that's my script, the firts part work (opening door), the second part dosn't work, i put the animation at -1.0 for to play it the contrary, but is wrong.
using UnityEngine; using System.Collections;
public class AnimationPlay : $$anonymous$$onoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.B)) {
animation.Play("New Animation");
}
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.A)) {
animation.Play("New Animation");
animation["New Animation"].speed = -1.0;
}
}
}
I edited script, now animation opens e closes, but after i press one time 'B' and 'A', the animation does not play more.. :(
// Update is called once per frame
void Update () {
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.B)) {
animation.Play("New Animation");
}
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.A)) {
animation["New Animation"].time = animation["New Animation"].length;
animation["New Animation"].speed = -1f;
animation.Play();
}
}
}