How do you run the next animation in a sequence, each time you enter OnTriggerStay on the same object?
Hey :) I hope this is not too confusing but i try to explain as much as possible, this is for a VR project.
For our school project, we need to make some kind of sequence of animations. there is one box for start. its on the top right of the model. the box itself is a trigger area (trigger zone) which means each time the hand object of our model enters the box, it will run OnTriggerStay.. now since this has to be some kind of fun excercise, we made the box move downwards. The problem now is each time you enter this box (also after the animation is done and the box is as its new position) it will retrigger.. thats some kind of a bug we dont know how to get rid of. The code we wrote itself sits in the OnTriggerStay function, so it makes sense that it reruns as soon as the hand is in the box.. but what we actually want is that this box from the position on the bottom now moves to the next location, when you put the hand in, not rerun the previous animation, but the next.
TLDR: You enter your hand into the box, box moves downwards to new location, should stay there and not retrigger animation when you put hand in again. This is the ultimate goal:
void OnTriggerStay (Collider other) {
//Play animation once
this.GetComponent<Animation>().Play()
//PLay this after first animation ended (or on second trigger)
this.GetComponent<Animation>().Play()
}
Answer by shadowpuppet · May 17, 2018 at 12:57 PM
is your animation set to looping or default or Once? I would be more specific about WHAT collider - just so nothing else but the hand is triggering the animation. But it also looks like you are playing the same animation. Name the animations and then call them as needed animation.Play("firstanim");
Our animation is not set for looping, and there is only one existent right now.
We need the animation to continue playing from point A to B and not reset each time we leave the trigger area. Our $$anonymous$$odel has a very small contact point on the finger, with a small sphere around it, as soon as this spehre collides with the box, it counts as OnTriggerEnter. Now you put your whole inside, that triggers the animation, which is a position change, slowly but s$$anonymous$$dily. now when the animation is finished, we want to be able to put the hand in again and it moves further, to a different direction, using the same animation process. So the state of the animation has to be stored somewhere And accessed each time the trigger is called To continue from that point
Your answer
Follow this Question
Related Questions
How too climb a ladder with the FPS Controller correctly 0 Answers
Animation on raycast enter trigger ? 0 Answers
Always wondered how to sync animations with attack effects 0 Answers
Unity animator always running only one animation...... 1 Answer
Player should turn in the direction the player is running. (2D Game) 0 Answers