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
- Unity CIL Linker fails on Player build when persistent listeners have "<" and ">" in their XML attribute names
- ”Lighting data asset ‘LightingData’ is incompatible with the current Unity version…” warnings are thrown when saving Indoors (URP) and Outdoors (URP) Scenes as Scene Templates
- [iOS] The screen blinks when transitioning from custom to Unity splash screen
- [macOS] ”Ignoring depth surface load action as it is memoryless” warnings are thrown when taking Game View Snapshot
- UI Builder Inspector scrolls back up when changes on an expanded but not fully displayed Inspector tab are saved
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;