Item Effects
ItemEffects are objects that have context of an ItemAction and have a InvokeEffect function. They are usually in a list called ItemEffectGroup and can be found on most usable items.
The ItemEffect is initialized by a CharacterItemAction.
Inspected Fields
Enabled
If the effect is not enabled it will not be invoked.
Delay
The effect can be delayed, this uses the Scheduler for delaying the function call.
Built-in Item Effects
There are a lot of ItemEffects and more will be added as time goes on.
To find a full list of the built-in ImpactActions use your IDE of choice (example Visual Studio) and look for all classes inheriting the ItemEffect class.
Debug Item Effect
Log a message when the effect is invoked to make sure it works.
Enable Disable Object
Enable or disable an object on Invoke.
Invoke Unity Event
Invokes the specified Unity Event.
Light Effect
Enable or disable a light and set the light intensity. This is used by the flashlight in the demo scene.
Play Audio Clip
Play and AudioClip using an AudioConfig or AudioClips. It is recommended to use an AudioConfig rather than set the audio clips directly
Spawn Prefab
Spawn a pooled prefab. This is used in the demo scene to spawn melee visual effects among other things.
Custom Item Effect
Making a custom ItemEffect is very easy by overriding the InvokeEffectInternal function:
/// <summary> /// Invoke a Unity Event. /// </summary> [Serializable] public class MyItemEffect : ItemEffect { [Tooltip("The Event to Invoke.")] [SerializeField] protected string m_Message; public string Message { get => m_Message; set => m_Message = value; } /// <summary> /// Can the effect be started? /// </summary> /// <returns>True if the effect can be started.</returns> public override bool CanInvokeEffect() { return true; } /// <summary> /// Invoke the effect. /// </summary> protected override void InvokeEffectInternal() { base.InvokeEffectInternal(); Debug.Log(m_Message+" "+m_CharacterItemAction, m_CharacterItemAction); } }