Forum rules - please read before posting.

Hook each and every hotspot tap, and hotspot interaction tap to trigger 3rd party code.

Hi there!

I'd love to add some sound (3rd party system) and haptic feedback on each and every interaction of the game.

This means, clicking on a hotspot (first hook), and clicking on an interaction that such hotspot causes to appear on screen (second hook).

also getting the world space point (or at least screen space coords) of such taps would be great!

Is there something similar for the tap-to-walk/to run interaction? (I was thinking about having the spawned VFX to handle that)

I'm looking for global hooks, since 99% of the interactions of the game are already ready to ship... and they're quite a lot :P

How would you manage this?

Could you please help me or point me in the right direction (snippets are welcome)?

Thank you.

Comments

  • As you mention clicking on an interaction, I take it your "Interaction method" is set to "Choose Hotspot Then Interaction"?

    This means, clicking on a hotspot (first hook), and clicking on an interaction that such hotspot causes to appear on screen (second hook).

    If clicking on a Hotspot results in the Interaction menu turning on, the first hook can be done with the OnMenuTurnOn event. The second with OnHotspotInteract.

    Details on how to use custom events are in the Manual's "Custom events" chapter, as well as this tutorial, but here's a snippet to demonstrate how these two event may be used:

    private void OnEnable ()
    {
        EventManager.OnMenuTurnOn += OnMenuTurnOn;
        EventManager.OnHotspotInteract += OnInteract;
    }
    
    private void OnDisable ()
    {
        EventManager.OnMenuTurnOn -= OnMenuTurnOn;
        EventManager.OnHotspotInteract -= OnInteract;
    }
    
    private void OnMenuTurnOn (Menu menu, bool isInstant)
    {
        if (menu.title == "Interaction")
        {
            Debug.Log ("The interaction menu was turned on");
        }
    }
    
    private void OnInteract (Hotspot hotspot, AC.Button button)
    {
        Debug.Log ("Hotspot " + hotspot + " was interacted with", hotspot);
    }
    

    also getting the world space point (or at least screen space coords) of such taps would be great!

    The screen-space mouse/tap position can be gotten with:

    KickStarter.playerInput.GetMousePosition ()
    

    There isn't an equivalent world-space position, though the world-space position of a given Hotspot's icon/centre-point can be gotten with:

    hotspot.GetIconPosition ()
    

    Is there something similar for the tap-to-walk/to run interaction? (I was thinking about having the spawned VFX to handle that)

    The OnCharacterSetPath event is triggered whenever a character is commanded to move along a path. You could try checking if the Player is moving during gameplay:

    private void OnEnable ()
    {
        EventManager.OnCharacterSetPath += OnCharacterSetPath;
    }
    
    private void OnDisable ()
    {
        EventManager.OnCharacterSetPath -= OnCharacterSetPath;
    }
    
    private void OnCharacterSetPath (AC.Char character, Paths path)
    {
        if (character.IsPlayer && KickStarter.stateHandler.IsInGameplay ())
        {
            Debug.Log ("Player moving during gameplay");
        }
    }
    
  • That's great!

    Thanks for the useful insight Chris! :)
    It was really simpler than I expected, thank you :)

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.