Class PlayFXAction
Action that plays a visual effect (FX) at a determined position, typically at the point of collision or interaction.
[Serializable]
public class PlayFXAction : BaseAction, IAction
- Inheritance
-
PlayFXAction
- Implements
- Inherited Members
Fields
FXPrefab
The FX prefab to play when this action is executed.
[Tooltip("The FX prefab to play.")]
public GameObject FXPrefab
Field Value
- GameObject
HeightOffset
Metres above the resolved position to play the effect. A target's or caster's position is its feet, so a burst meant to wrap the body lifts by about a metre; a ground ring keeps 0.
[Tooltip("Metres above the resolved position. A character's position is its feet: ~1 wraps the body, 0 keeps a ground ring on the ground.")]
public float HeightOffset
Field Value
Size
The effect's size in metres, or 0 to play it at the prefab's own scale.
[Tooltip("The effect's size in metres (FX are authored to a 1 m cube). 0 keeps the prefab's own scale. An area effect of radius r uses 2r.")]
public float Size
Field Value
Remarks
Ability effects are authored to fit a one-metre cube (ParticleAdjuster, "Scale Particle System to Fit Cube"), and play in the Hierarchy scaling mode, so the instance's scale is its size: an area effect of radius r sets this to 2r and fills exactly the volume it acts on.
Properties
IsPresentation
Purely presentational: particles and nothing else.
public override bool IsPresentation { get; }
Property Value
Remarks
This is the one action in the project whose whole effect is a rendered object, so it is the one action that may still run on a peer whose selector declined to resolve — see IsPresentation.
Methods
Execute(ICharacter, EventData)
Plays the FX prefab at the collision or interaction location.
public override void Execute(ICharacter initiator, EventData eventData)
Parameters
initiatorICharacterThe character initiating the action.
eventDataEventDataThe event data containing collision or interaction information.
Remarks
The FX is spawned wherever TryResolveSpawnPosition(ICharacter, EventData, out Vector3) lands — the impact point a CollisionEventData carries, then the event's own target, then the ability object the event belongs to, then the initiator.
It used to read Collision.contacts[0]. That threw as soon as anything dispatched a
hit without a Unity collision — AbilityApplyAreaAction always did, and now
every ability hit does, because AbilityObject resolves them with a swept
query so they can be lag compensated. The event carries the impact point directly instead.
VFX instantiation is suppressed during prediction replay ticks to prevent visual spam.
The instance this creates is the action's responsibility. It is placed in the scene the effect happened in rather than the active one, and is handed to FXInstanceLifetime so that it ends whether or not its prefab knows how to end itself. Both are what the action previously left to chance; see issue #258 for what that cost, and ResolveSpawnScene(ICharacter, EventData) and FXInstanceLifetime for the two halves of it.