Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Play interaction only if hotspot is reachable

edited March 2020 in Technical Q&A

Hi!

Every post to this forum I want to start with gratitude to Chris and community! Thanks a lot for Adventure Creator!

I've got a little predicament. My character is stuck (and so am I) at some kind of a device. My movement method is 'Point And Click', interaction method is 'Choose Interaction Then Hotspot'. I'm constraining movement of the character with specific action:

My hotspot has 'Walk to marker' player action:

When I'm clicking on the hotspot with my character's movement constrained, hotspot's interaction is performing immediately and also the character is turning to the hotspot.

I want the character:
1) to be immobilized completely (yet face this hotspot at normal mode, so I can't uncheck 'Face after moving' flag)
2) to not play interaction of unreachable hotspot, just do nothing in case when he can't walk to marker

I can't disable the hotspot, 'cause I have different cursor interactions, and some of them (ruling the drone, for example) should work as usual even when the character is immobilized. Also I cannot disable the 'hand' cursor completely so the character can interact with the device holding him.

I can disable 'hand' cursor for this hotspot like this:

But I've got plenty of hotspots and interactions and inventory items, so I'm afraid that would be rather difficult to disable all of them. Maybe I should write a Custom Action for automatic massive disabling? But maybe there is some kind of a trick in the engine already? =)

Could you please help me?

Thank you!

Comments

  • You mention inventory items only at the very end - are you talking about interacting with items themselves - or using them with Hotspots?

    Probably is best to have a script that disables "Hand" interactions en-masse. If you give all Hotspots you want to affect a special tag, you can then use that tag in the script. You can also set the state of such interactions based on the Player's movement lock:

    void UpdateInteractions ()
    {
        bool disable = !AC.KickStarter.playerInput.CanDirectControlPlayer ();
        foreach (AC.Hotspot hotspot in AC.KickStarter.stateHandler.Hotspots)
        {
            if (hotspot.gameObject.tag == "CannotReach")
                hotspot.GetUseButton (0).isDisabled = disable;
        }
    }
    

    Place that inside a new C# script, attach it to a GameObject, and make it a prefab. You can then use the Object: Call event Action to call that prefab's "UpdateInteractions" function after the Player: Constrain Action. This will disable/enable all Hotspots tagged with "CannotReach" automatically.

  • edited March 2020

    Thanks a lot! It works great! I need to disable inventory interactions too, so I've added the following code [and it works too for my surprise =)]:
    foreach (var invButton in hotspot.invButtons) invButton.isDisabled = disable;

    [upd: for some reason I can't make a beautiful format of my code snippet]

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.