Skip to content

Commit 181d00d

Browse files
authored
fix: missing particles in backpack while viewing emotes (#6121)
1 parent 152a8bb commit 181d00d

File tree

6 files changed

+197
-58
lines changed

6 files changed

+197
-58
lines changed

unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimationEventHandler.cs

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
using System.Collections;
2-
using System.Collections.Generic;
32
using UnityEngine;
43
using DCL;
54

65
public class AvatarAnimationEventHandler : MonoBehaviour
76
{
8-
const string FOOTSTEP_NAME = "footstep", HEART_NAME = "heart";
9-
const string ANIM_NAME_KISS = "kiss", ANIM_NAME_MONEY = "money", ANIM_NAME_CLAP = "clap", ANIM_NAME_SNOWFLAKE = "snowfall", ANIM_NAME_HOHOHO = "hohoho";
10-
const float MIN_EVENT_WAIT_TIME = 0.1f;
11-
const float HOHOHO_OFFSET = 1.5f;
7+
private const string FOOTSTEP_NAME = "footstep", HEART_NAME = "heart";
8+
private const string ANIM_NAME_KISS = "kiss", ANIM_NAME_MONEY = "money", ANIM_NAME_CLAP = "clap", ANIM_NAME_SNOWFLAKE = "snowfall", ANIM_NAME_HOHOHO = "hohoho";
9+
private const float MIN_EVENT_WAIT_TIME = 0.1f;
10+
private const float HOHOHO_OFFSET = 1.5f;
1211

13-
AudioEvent footstepLight;
14-
AudioEvent footstepSlide;
15-
AudioEvent footstepWalk;
16-
AudioEvent footstepRun;
17-
AudioEvent clothesRustleShort;
18-
AudioEvent clap;
19-
AudioEvent throwMoney;
20-
AudioEvent blowKiss;
12+
private AudioEvent footstepLight;
13+
private AudioEvent footstepSlide;
14+
private AudioEvent footstepWalk;
15+
private AudioEvent footstepRun;
16+
private AudioEvent clothesRustleShort;
17+
private AudioEvent clap;
18+
private AudioEvent throwMoney;
19+
private AudioEvent blowKiss;
2120

22-
Animation anim;
21+
private Animation anim;
2322

24-
float lastEventTime;
23+
private float lastEventTime;
2524

26-
StickersController stickersController;
25+
private StickersController stickersController;
2726

28-
Transform footL;
29-
Transform footR;
30-
Transform handL;
31-
Transform handR;
27+
private int renderingLayer;
3228

33-
public void Init(AudioContainer audioContainer)
29+
private Transform footL;
30+
private Transform footR;
31+
private Transform handL;
32+
private Transform handR;
33+
34+
public void Init(AudioContainer audioContainer, int renderingLayer)
3435
{
3536
if (audioContainer == null)
3637
return;
3738

39+
this.renderingLayer = renderingLayer;
40+
3841
footstepLight = audioContainer.GetEvent("FootstepLight");
3942
footstepSlide = audioContainer.GetEvent("FootstepSlide");
4043
footstepWalk = audioContainer.GetEvent("FootstepWalk");
@@ -65,13 +68,13 @@ public void Init(AudioContainer audioContainer)
6568
public void AnimEvent_FootstepRunLeft()
6669
{
6770
PlayAudioEvent(footstepRun);
68-
PlaySticker(FOOTSTEP_NAME, footL.position, Vector3.up);
71+
PlaySticker(FOOTSTEP_NAME, footL.position, Vector3.up, renderingLayer: renderingLayer);
6972
}
7073

7174
public void AnimEvent_FootstepRunRight()
7275
{
7376
PlayAudioEvent(footstepRun);
74-
PlaySticker(FOOTSTEP_NAME, footR.position, Vector3.up);
77+
PlaySticker(FOOTSTEP_NAME, footR.position, Vector3.up, renderingLayer: renderingLayer);
7578
}
7679

7780
public void AnimEvent_ClothesRustleShort() { PlayAudioEvent(clothesRustleShort); }
@@ -85,7 +88,7 @@ public void AnimEvent_Clap()
8588
return;
8689

8790
PlayAudioEvent(clap);
88-
PlaySticker(ANIM_NAME_CLAP, handR.position, Vector3.up, true);
91+
PlaySticker(ANIM_NAME_CLAP, handR.position, Vector3.up, true, renderingLayer: renderingLayer);
8992
UpdateEventTime();
9093
}
9194

@@ -98,7 +101,7 @@ public void AnimEvent_ThrowMoney()
98101
return;
99102

100103
PlayAudioEvent(throwMoney);
101-
PlaySticker(ANIM_NAME_MONEY, handL.position, handL.rotation.eulerAngles, true);
104+
PlaySticker(ANIM_NAME_MONEY, handL.position, handL.rotation.eulerAngles, true, renderingLayer: renderingLayer);
102105
UpdateEventTime();
103106
}
104107

@@ -115,10 +118,10 @@ public void AnimEvent_BlowKiss()
115118
UpdateEventTime();
116119
}
117120

118-
IEnumerator EmitHeartParticle()
121+
private IEnumerator EmitHeartParticle()
119122
{
120123
yield return new WaitForSeconds(0.8f);
121-
PlaySticker(HEART_NAME, handR.position, transform.rotation.eulerAngles, true);
124+
PlaySticker(HEART_NAME, handR.position, transform.rotation.eulerAngles, true, renderingLayer: renderingLayer);
122125
}
123126

124127
public void AnimEvent_Snowflakes()
@@ -129,27 +132,27 @@ public void AnimEvent_Snowflakes()
129132
if (!AnimationWeightIsOverThreshold(0.2f, ANIM_NAME_SNOWFLAKE))
130133
return;
131134

132-
PlaySticker("snowflakes", transform.position, Vector3.zero, true);
135+
PlaySticker("snowflakes", transform.position, Vector3.zero, true, renderingLayer: renderingLayer);
133136
}
134137

135138
public void AnimEvent_Hohoho()
136139
{
137140
if (LastEventWasTooRecent())
138141
return;
139-
142+
140143
if (!AnimationWeightIsOverThreshold(0.2f, ANIM_NAME_HOHOHO))
141144
return;
142145

143-
PlaySticker(ANIM_NAME_HOHOHO, transform.position + Vector3.up * HOHOHO_OFFSET, Vector3.zero, true);
146+
PlaySticker(ANIM_NAME_HOHOHO, transform.position + Vector3.up * HOHOHO_OFFSET, Vector3.zero, true, renderingLayer: renderingLayer);
144147
}
145148

146-
void PlayAudioEvent(AudioEvent audioEvent)
149+
private void PlayAudioEvent(AudioEvent audioEvent)
147150
{
148151
if (audioEvent != null)
149152
audioEvent.Play(true);
150153
}
151154

152-
bool AnimationWeightIsOverThreshold(float threshold, string animationName)
155+
private bool AnimationWeightIsOverThreshold(float threshold, string animationName)
153156
{
154157
if (anim != null)
155158
{
@@ -170,25 +173,23 @@ bool AnimationWeightIsOverThreshold(float threshold, string animationName)
170173
return false;
171174
}
172175

173-
void UpdateEventTime()
176+
private void UpdateEventTime()
174177
{
175178
lastEventTime = Time.realtimeSinceStartup;
176179
}
177180

178-
bool LastEventWasTooRecent()
179-
{
180-
return lastEventTime + MIN_EVENT_WAIT_TIME >= Time.realtimeSinceStartup;
181-
}
181+
private bool LastEventWasTooRecent() =>
182+
lastEventTime + MIN_EVENT_WAIT_TIME >= Time.realtimeSinceStartup;
182183

183184
/// <summary>
184185
/// Plays a sticker.
185186
/// </summary>
186187
/// <param name="id">ID string of sticker</param>
187188
/// <param name="position">Position in world space</param>
188189
/// <param name="rotation">Euler angles</param>
189-
void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform = false)
190+
private void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform = false, int renderingLayer = 0)
190191
{
191192
if (stickersController != null)
192-
stickersController.PlaySticker(id, position, direction, followTransform);
193+
stickersController.PlaySticker(id, position, direction, followTransform, renderingLayer);
193194
}
194-
}
195+
}

unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarAnimatorLegacy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class BlackBoard
8383

8484
[SerializeField] internal AvatarLocomotion femaleLocomotions;
8585
[SerializeField] internal AvatarLocomotion maleLocomotions;
86+
[SerializeField] internal string renderingLayer = "Default";
8687
private AvatarLocomotion currentLocomotions;
8788

8889
public new Animation animation;
@@ -550,7 +551,7 @@ private void InitializeAvatarAudioAndParticleHandlers(Animation createdAnimation
550551

551552
if (audioContainer != null)
552553
{
553-
animationEventHandler.Init(audioContainer);
554+
animationEventHandler.Init(audioContainer, LayerMask.NameToLayer(renderingLayer));
554555

555556
//NOTE(Mordi): If this is a remote avatar, pass the animation component so we can keep track of whether it is culled (off-screen) or not
556557
AvatarAudioHandlerRemote audioHandlerRemote = audioContainer.GetComponent<AvatarAudioHandlerRemote>();

unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarShape.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ MonoBehaviour:
9191
baseAvatarContainer: {fileID: 4288110136316019743}
9292
baseAvatarReferencesPrefab: {fileID: 4766333532709993497, guid: 7bf2abf753051c34c9e0a568a90fc0f0,
9393
type: 3}
94-
boneAnchors: []
9594
everythingIsLoaded: 0
9695
--- !u!114 &122622683908687435
9796
MonoBehaviour:
@@ -165,6 +164,7 @@ MonoBehaviour:
165164
run: {fileID: 7400000, guid: 916369dcf45c5944e9f2409e0be10181, type: 2}
166165
jump: {fileID: 7400000, guid: b51f09eb09017384a8ff4b3b88b00c00, type: 2}
167166
fall: {fileID: 7400000, guid: cd48d8cde6039fa4fac548ddab2ff277, type: 2}
167+
renderingLayer: Default
168168
animation: {fileID: 0}
169169
blackboard:
170170
walkSpeedFactor: 0.3

0 commit comments

Comments
 (0)