Forum rules - please read before posting.

"Triggers Interaction Instantly" on exit hotspot

Hi everybody,
AC 1.77.4 and Unity LTS 2022.3.3f1 in 2d.

I have an exit hotspot (a hotspot with a Camera Fade Out + Scene Switch actions). When I use the "Triggers Interaction Instantly" on the "Double clicking" option, without "Snap if double-click" option, the character faces to the hotspot before switch scene.

I tried to checked/unchecked "face after moving" option but character always faces to hotspot. Is it possible to have the trigger without character faces to hotspot? So for example, if I have an exit hotspot on the right and my character is on the left faced of the screen, I'd like to doubleclick on the hotspot without the character turn in the hotspot direction.

Thank you very much.

Comments

  • As the Player will begin moving towards the Hotspot with the first click, the turning may be due to that movement command - rather than specifically due to the double-click.

    What you could try is attaching a script to the Hotspot that stops the Player from turning once they reach it. Something like:

    using UnityEngine;
    using AC;
    
    public class HotspotSnapFix : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotReach += OnHotspotReach; }
        private void OnDisable () { EventManager.OnHotspotReach -= OnHotspotReach; }
    
        private void OnHotspotReach (Hotspot hotspot, AC.Button button)
        {
            if (hotspot.gameObject == gameObject)
                KickStarter.player.StopTurning ();
        }
    
    }
    
  • I'll try, thank you very much

  • Hi Chris,
    we tried, but the script seems to work on the double click and not on the first click (so the player turns).
    Do you know if it could be any other workaround?
    With the previous version of AC we have a script to solve the double click position (before the last upgrades), but now the structure of AC script changed a lot so our modified version doesn't work.

    Thank you very much.

  • Perhaps I'm misunderstanding your intent - is the Player not supposed to move on the first click?

    Best start over, and let me know the exact behaviour you're looking for with both clicks - visuals would be welcome as well, is possible.

    With the previous version of AC we have a script to solve the double click position (before the last upgrades), but now the structure of AC script changed a lot so our modified version doesn't work.

    Which previous version, and what's the script?

  • Hi Chris, sorry, probably, I didn't explain well.
    I'd like the player doesn't turn when we use the trigger with double click. At the moment, if you double click, the player turn and then switch the scene. I'd like to double click and only switch the scene.

    I'm searching for previous script and send it to you.

    Thank you.

  • edited September 2023

    And when they single-click?

    As you said, the script above works when you double-click. I'm not clear on the difference.

  • Hello Chris,
    here a screenshot and a video to illustrate the "issue". The screenshot is about the hotspot (camera fade + switch scene): https://drive.google.com/file/d/1FWn_jO4KGYJ7Rxu7op1SVjRLFzkQfdv9/view?usp=sharing

    The video is about the behaviour on single click (the player goes to the marker of the hotspot and faces to it, then camera fade and switch (till 5 sec)) and double click (sec 5). I know it's only for a while, but you can see the player turns to the hotspot: https://drive.google.com/file/d/1l3hLCg884Z3nInF41HLSzNjMjOD496Yr/view?usp=sharing

    In the previous version of AC the player doesn't turn, but the script only triggers the hotspot actions (so camera fade and switch). Is it possible to avoid the player rotation?

    Thank you very much.

  • edited September 2023

    and here the link to a old version of the script (we changed something because there are some issue with the double click (at that time the player shows in the marker position before the switch of the scene)): [REDACTED]

  • I've removed the link to your script - please do not post AC's source code in public.

    The behaviour you describe is as I understood it. You mentioned "it works on the double click", which is intended - the double-click should prevent the player from turning. I'm not clear what you meant by this.

    Is the video made with the script above attached to the Hotspot? If so, try replacing OnHotspotReach with OnDoubleClickHotspot.

  • Hi Chris, sorry for the link to the script.
    The video is made with the standard AC script (1.77.4).

    I'll try with the solution proposed.

    Thank you.

  • Hi Chris, I tried with OnDoubleClickHotspot but it doesn't work. It seems to work on the second click, but the player turns on the first click.

  • edited September 2023

    As expected, from the sound of it. The first click will be treated as a "single click", i.e. cause the regular "Move to" behaviour to kick in - since it doesn't yet know you're going to follow this up with a double-click.

    Getting around that would be a bit tricky. As I see it, you'd need to:

    1/ Split your Interaction ActionLists into Single- and Double-Click variants
    2/ Set the Single variant to Run In Background, and have run a Character: Move to point Action to move the Player, followed by an ActionList: Run Action to then run the Double-click variant (which just fades and switches scene)
    3/ Clear the Interaction object from the Hotspot's "Use interaction" panel, and also set the Player action to Do nothing
    4/ Attach a custom script to the Hotspot to call the Interactions manually:

    using UnityEngine;
    using AC;
    
    public class DelaySingleClick : MonoBehaviour
    {
    
        public Interaction onSingleClick;
        public Interaction onDoubleClick;
        public float waitTime = 0.2f;
    
        private void OnEnable () { EventManager.OnHotspotInteract += OnHotspotInteract; }
        private void OnDisable() { EventManager.OnHotspotInteract -= OnHotspotInteract; }
    
        private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
        {
            if (hotspot.gameObject == gameObject)
            {
                bool isDouble = KickStarter.playerInput.ClickedRecently (true);
                if (isDouble)
                {
                    CancelInvoke ();
                    onDoubleClick.Interact ();
                }
                else
                {
                    Invoke ("SingleClick", waitTime);
                }
            }
        }
    
        private void SingleClick ()
        {
            onSingleClick.Interact ();
        }
    
    }
    
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.