This script lets you set the number of times a scene-based ActionList (i.e. a Cutscene / Interaction / Trigger) can be run. If the limit has been exceeded, an alternative ActionList can be run in its place.
To use it:
- Create a new C# script named ActionListRepeater.cs, and paste in the code below
- Attach the new "Action List Repeater" component to the scene-based ActionList you wish to limit
- In its Inspector, set its "Repeatable Amount" value and (optionally) an "ActionList On Fail".
public class ActionListRepeater : MonoBehaviour
public int repeatableAmount = -1;
public ActionList actionListOnFail;
private int timesPlayed;
private void OnEnable ()
EventManager.OnBeginActionList += OnBeginActionList;
private void OnDisable ()
EventManager.OnBeginActionList -= OnBeginActionList;
private void OnBeginActionList (ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
if (repeatableAmount >= 0 && actionList == GetComponent <ActionList>())
if (timesPlayed > repeatableAmount)
if (actionListOnFail) actionListOnFail.Interact ();
Community content is available under CC-BY-SA unless otherwise noted.