Hi,
So I have this script, which is meant to play a restart actionlist after a set period of time when no input has been detected, but it doesn't seem to be working, can you help at all?
using UnityEngine;
using AC;
public class RespondToWaitAsset : MonoBehaviour
{
public float waitTime = 10f;
public ActionListAsset actionList;
private float timer;
private int expoGlobalVariableID = 96; // Replace 96 with the actual ID of the Expo global variable
void Start()
{
// Initialize the timer to 0
timer = 0f;
// Check if actionList is assigned
if (actionList == null)
{
Debug.LogError("ActionListAsset is not assigned in the Inspector");
}
}
void Update()
{
// Retrieve the value of the global boolean variable Expo
bool isExpoEnabled = AC.GlobalVariables.GetBooleanValue(expoGlobalVariableID);
if (isExpoEnabled) // Check if the global variable Expo is set to true
{
// Check player conditions
if (KickStarter.player != null &&
KickStarter.player.charState == CharState.Idle &&
!KickStarter.player.isTalking &&
KickStarter.stateHandler.IsInGameplay())
{
// Increment timer
timer += Time.deltaTime;
// Check if timer has reached wait time
if (timer >= waitTime)
{
// Reset timer
timer = 0f;
// Trigger the action list
if (actionList != null)
{
actionList.Interact();
}
else
{
Debug.LogWarning("ActionListAsset is not assigned");
}
}
}
else
{
// Reset timer if conditions are not met
timer = 0f;
}
}
else
{
// Reset timer if Expo is not enabled
timer = 0f;
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I have no issue with it on my end.