You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.Multiplayer.Samples.BossRoom.Client
|
|
{
|
|
/// <summary>
|
|
/// Component to play VFX and SFX when this NetworkObject's parent NetworkObject changes to make the action look more polished.
|
|
/// </summary>
|
|
public class ClientPickUpPotEffects : NetworkBehaviour
|
|
{
|
|
[SerializeField]
|
|
ParticleSystem m_PutDownParticleSystem;
|
|
|
|
[SerializeField]
|
|
AudioSource m_PickUpSound;
|
|
|
|
[SerializeField]
|
|
AudioSource m_PutDownSound;
|
|
|
|
void Awake()
|
|
{
|
|
enabled = false;
|
|
}
|
|
|
|
public override void OnNetworkSpawn()
|
|
{
|
|
enabled = IsClient;
|
|
}
|
|
|
|
public override void OnNetworkObjectParentChanged(NetworkObject parentNetworkObject)
|
|
{
|
|
if (!IsClient)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (parentNetworkObject == null)
|
|
{
|
|
m_PutDownParticleSystem.Play();
|
|
m_PutDownSound.Play();
|
|
}
|
|
else
|
|
{
|
|
m_PickUpSound.Play();
|
|
}
|
|
}
|
|
}
|
|
}
|