Forum rules - please read before posting.

How to prevent hotspot interaction via custom scripts while character is still moving ?

Hey everyone,

In Adventure Creator's hotspot "Use Interaction" section, we can set the Player action to Walk To Marker, which makes the character walk to the marker before running the interaction.
My question is: How can we prevent this interaction from running via custom scripts while the character is still moving?

Here’s how I capture the hotspot and button:
`
public AC.Hotspot currentInteractHotspot {
get; private set;
}
public AC.Button currentInteractButton {
get; private set;
}

void OnEnable()
{
    AC.EventManager.OnHotspotInteract += this.OnHotspotInteract;
}

void OnDisable()
{
    AC.EventManager.OnHotspotInteract -= this.OnHotspotInteract;
}

private void OnHotspotInteract(AC.Hotspot hotspot, AC.Button button)
{
    this.currentInteractHotspot = hotspot;
    this.currentInteractButton = button;
}`  

I tried to stop the interaction with this code:
`
player.Halt();

            AC.Hotspot hotspot = CustomEventManager.instance.currentInteractHotspot;
            if(hotspot != null)
            {
                Debug.Log("hotspot is turnning off");
                hotspot.TurnOff();
            }

            AC.Button button = CustomEventManager.instance.currentInteractButton;
            if(button != null && button.interaction != null)
            {                    
                if(button.interaction.AreActionsRunning())
                {
                    Debug.Log("button is killed");
                    button.interaction.Kill();
                }
                else
                {
                    Debug.Log("button is EndCutscene");
                    KickStarter.stateHandler.EndCutscene ();
                }
            }`

Problem:
* player.Halt() and hotspot.TurnOff() do not work.
* button.interaction.Kill() only works if the interaction is already running.
* While the character is moving (before interaction starts), I can’t find a way to cancel it.

Observation:
When clicking multiple hotspots quickly, the character walks to each marker, but only the last interaction runs. This suggests there should be a way to cancel pending interactions.

Environment:
Unity 2019.4.40 & AC 1.70.2 (legacy project).

Any help would be appreciated!

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.