The Magic Item Action is an extremely flexible Item Action which allows the item to perform a wide variety of magic and spell related actions. The Magic Item relies on sub-actions to perform the actual work: BeginActions, CastActions, ImpactActions, and EndActions. Using the sub-actions the Magic Item can spawn particles, objects, surface effects, audio, etc. New actions can be created by implementing the base class.

Begin/End Actions

Begin Actions starting playing at the start of the item use until the Use event is sent.When the Use event occurs the Cast Action will trigger. For Single Use Type Magic Items the End Actions will start playing immediately after the Use event occurs. Continuous Use Type Magic Items will start playing the End Action when the Magic Item is starting to be stopped. Both actions will stop when the item is no longer being used.

Begin and End Actions implement the same base class so the same object can be used for either the start or end of the Magic Item use. These actions allow for starting or ending effects effects, such as starting to fade the character before a teleport or spawn a local particle system that should occur after the actual cast.

Fade Material

Fades the materials on the character.

Play Audio Clip

Plays an audio clip.

Spawn Particle

Spawns a particle.

Cast Actions

Cast Actions are the primary sub-action within the Magic Item. Cast Actions occur when the Use event is sent and is the main visual that you see for the Magic Item. Common cast actions include spawning a particle, but other cast actions can spawn any arbitrary object or start an effect on the character.

When a Cast Action collides with an object it can start an Impact Action. This allows for effects to be played at the impact location.

Physics Cast

Uses the physics system to determine the impacted object.

Play Audio Clip

Plays an audio clip when the cast is performed.

Spawn Object

Spawns an object when the cast is performed.

Spawn Particle

Spawns a particle when the cast is performed.

Spawn Projectile

Spawns a projectile when the cast is performed.

Start Effect

Starts an effect on the character.

Target Impact

Immediately calls impact on the object at the target position.

Teleport

Teleports the character.

Impact Actions

Impact Actions play an effect at the location determined by the Cast Action. Frequent Impact Actions will be to spawn a particle or change an Attribute value.

Add Force

Adds a force to the impacted object.

Add Torque

Adds a torque to the impacted object.

Damage

Damages the impacted object.

Heal

Heals the impacted object.

Modify Attribute

Modifies the specified attribute on the impacted object.

Play Audio Clip

Plays an AudioClip on the impacted object.

Ricochet

The Ricochet action will cast a new CastAction for nearby objects, creating a ricochet effect.

Spawn Particle

Spawns a ParticleSystem upon impact.

Spawn Surface Effect

Spawns a SurfaceEffect upon impact. The SurfaceImpact object is specified on the MagicItem.

Collision

When a Cast Action effect plays it can collide with other objects to play an Impact Action. This collision can occurs with one of the following methods:

Particle Collision

Unity’s Particle System has the option of sending collision messages when the particle collides with another object. In order for the collision message to be received the Magic Particle component must be added to the Particle System that can cause the collision.

 

Projectile

The Magic Projectile component will trigger an impact when it collides with another object. The Magic Particle component uses the Trajectory Object component to do its actual movement.

Raycast

If the Physics Cast Cast Action is used then a raycast will be performed when the Cast Action is run. This raycast will execute the Impact Actions immediately.

Inspected Fields

Require Grounded

Is the character required to be on the ground?

Direction

The direction of the cast.

  • None: The cast has no movement.
  • Forward: The cast should move in the forward direction.
  • Target: The cast should move towards a target.
  • Indicate: The cast should move towards an indicated position.
Use Look Source

Should the look source be used when determining the cast direction?

Max Distance

The maximum distance of the movement cast direction.

Radius

The radius of the movement cast direction.

Detect Layers

The layers that the movement directions can collide with.

Max Angle

The maximum angle that the target object can be compared to the character’s forward direction.

Max Collision Count

The maximum number of colliders that can be detected by the target cast.

Target Count

The number of objects that a single cast should cast.

Surface Indicator

The transform used to indicate the surface. Can be null.

Surface Indicator Offset

The offset when positioning the surface indicator.

Use Type

Specifies how often the cast is used.

  • Single: The cast should occur once per use.
  • Continuous: The cast should occur ever use update.
Min Continuous Use Duration

The minimum duration of the continuous use type. If a value of -1 is set then the item will be stopped when the stop is requested.

Continuous Cast

Should the continuous use type cast every update?

Use Amount

The amount of the ItemIdentifier that should be used each cast.

Interrupt Source

Specifies when the cast should be interrupted.

  • Movement: The cast should be interrupted when the character moves.
  • Damage: The cast should be interrupted when the character takes damage.
Surface Impact

The SurfaceImpact of the cast.

Can Stop Substate Index Addition

The value to add to the Item Substate Index when the item can stop.