Search Issue Tracker
By Design
Votes
0
Found in
2022.3.54f1
6000.0.31f1
6000.1.0a8
6000.2.0a1
Issue ID
UUM-90786
Regression
No
Animation events trigger twice when using blend trees with non-zero weights
Reproduction steps:
1. Open the attached “repro_IN-90638“ project
2. Open the “Assets/Scenes/SampleScene.unity“ Scene
3. Enter the Play Mode
4. Wait until the skeleton moves on top of you
5. Hit the skeleton by pressing the left mouse button
6. Observe the Console
Expected result: Debug.Log messages indicate that the skeleton was hit one time
Actual result: Debug.Log messages indicate that the skeleton was hit two times
Reproducible with: 2022.3.54f1, 6000.0.31f1, 6000.1.0a8
Couldn’t test with: 2021.3.47f1 - Not able to fix non-working Components after downgrading the Cinemachine package
Reproducible on: Windows 10 (22H2), Windows 11 (23H2) (user’s environment)
Not reproducible on: No other environments tested
Note: Reproducible in Player
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Objects with Universal Render Pipeline/Particles/Lit shader are always lit up when changing their Rendering Layer Mask
- PolySpatial “Trying to set shader on a Material Variant.” error is printed in the console when entering Play Mode
- Error “Shader error in 'YSCloudCover': call to 'tex3D' is ambiguous at Assets/YSCloudCoverText.shader(606) (on d3d11)“ is present when compiling tex3D shader with DXC
- Placeholder asset is not loaded with Advertisement Legacy sample when using the latest version of the package
- Addressables content build fails but the Player build is successful when building a development build
Resolution Note:
This is as intended. (see https://discussions.unity.com/t/mecanim-5-blend-tree-animation-event-called-twice/576456/8). Blend trees mean that several clips are run at the same time, and we do want events from all of them, even if they do not make sense in some cases (like yours for the sprite base animation), but it makes sense for many others situation.
One proposed workaround that I tested on the provided project is therefor to pass the animationEvents in the function
public void DealDamage(AnimationEvent evt)
and in the event, pass the old int parameter in the int field. then, you can add code to verify, is the weight of the current animation <0.5?
if (evt.animatorClipInfo.weight < 0.5)
return;