Skip to main content

ParticlesToPlayer

A class in Root.Township, Features.Visual_Effects.General_Scripts.

Plays a VfxData particle trail that flies from an origin to a given player. The VFX data is saved and sent to joining players; TriggerForPlayer plays it locally and does nothing on a headless server.

Constructors​

MemberWhat it is
ParticlesToPlayer()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private Transform originWhere the particles start when not starting from the player.
private MethodSync syncSetupMethod sync for the VFX data reference.
private EntityMessageType uniqueMessageChannelMessage type used for the sync, default VfxData. Change it if another behaviour on the entity uses that channel.
private bool usePlayerFeetAsOriginStart the particles at the player instead of origin. The code ends up placing them at the head.
private VfxData vfxDataThe effect to play. Saved.

Methods​

MemberWhat it is
override void Initialize()Creates the setup sync on uniqueMessageChannel.
void Load(ParticlesToPlayerSaveData data, ISerializeChildren childSerializer)Restores the VFX data reference from save data.
override void OnConnected(Player player)Server: sends the VFX data reference to the joining player.
ParticlesToPlayerSaveData Save(ISerializeChildren childSerializer)Saves the VFX data reference.
void TriggerForPlayer(Player player)Not on headless: spawns the particles at origin (or at the player's head when usePlayerFeetAsOrigin is set) and moves them to the player.
1 private and internal method
MemberWhat it is
private void SyncSetup(IPlayer player, Stream stream)Server to client: sends the VFX data reference. Logged as unauthorized if a client sends it.