I’ve searched for an answer to this with no results.
I have an issue that I cant solve. I have two layers for an avatar. An upperbody layer and a lowerbody layer. I have an event to play foot step sounds on my walk and run animations. But the event is getting called on the walk and run animation twice per footstep if the upper and lower layers are both running the walk and run animation.
I tried setting the mask in the animation to only include lowerbody joints hoping that would help but it only affects the animation. If I set the lowerbody layer to walk/run and the upperbody layer to something else, like Idle for instance, the event only does the foot step sounds for the lower body like it should. But I want to be able to run the upperbody walk/run as well.
Any idea on how I can solve this? Any help is appreciated.
Hi, I stumbled upon a similar problem when using BlendTrees for animations. When blending between walk and run, it would call the footsteps for both walk AND run. My first idea was to only put events on run, so that when blended in a BlendTree, only run would be called. But if it blended to just walk, you would get no sounds.
The second solution was to limit the amount of calls that could happen within a given second based off of velocity, but the system ended up too complex, and didn’t add support for crazier speeds.
Finally I noticed you could add parameters to Events in the import window. So I set up a simple system that passed in the number 1 for walk and 2 for run. Then I would check the speed of the character and if it was slow, then accept 1, if it was fast, accept run. Now your problem seems to be a little different, but the same basic concept applies.
Assuming your run for upper and lower body are the same animation, you would’ve separated it into 2 layers. However, I’m guessing you placed the event on just that one animation, for walk or run. So that when you play it on 2 layers, it is called twice. The easiest fix, therefore, would be to import the animation twice from the window, and change the event so that one of them has parameter 1, and the other parameter 2. (Or even better, just don’t have an event on the other one) Then call parameter 1, the original animation on the lower body, and use the duplicated animation for the other layer. Since the duplicated animation will have no events, it can only be called once. (This is assuming you are not blending or any other weird Mecanim things) Good luck!
Ah I never thought of that. Making a duplicate animation of the walk/run to use on the upperbody. Thanks for the idea! I’ll give it a try and let you know.
EDIT: Yes that did the trick!
Isn’t there some other way to do this without having duplicate animations because I don’t think that solution is feasible when having ~10 or more different walk animations for different stances…
I’m currently facing the same problem where I have the animation playing on two layers and so my animation event gets called twice.
Update:
I ended up working around it by only executing the contents of my Animator Event method every X number of seconds, where X is something like 0.05 - 0.1 so that although it gets called multiple times, I only use one of those calls.
This workaround was enough for my scenario (footsteps) but your mileage may vary.
Just a thought: Would it be possible to double check the position of the animation when you run the event, and decide how to run it, if at all, based on that information?
Hello there. Has anybody solved this in some proper way?
There really got to be a proper solution for this. It’s already a layered animation system yet the events do not distinguish between layers.