Forum rules - please read before posting.

Can hotspots be interacted with independent of the player's proximity?

edited February 2019 in Technical Q&A

I'm currently trying to overhaul the existing control scheme for my 2D direct controlled game.
Existing scheme: Hotspot detection method - player vicinity. The player stands within the bounds of the hotspot, and presses E/ clicks the hotspot to bring up the interaction menu.

New scheme: Detection method - mouse over. The player can stand in one spot, and just hover the mouse over every hotspot that's visible in the scene. This works, as in upon hovering the cursor over hotspot highlights the hotspots But, only those hotspots that are intersecting with the player's box collider 2D are the ones that can be clicked on, bringing up the interaction menu. The rest which are outside the bounds are highlighted successfully but can't be clicked on. Is this by design, or is this supposed to not happen?

A workaround would be to enlarge the player's box collider so that it covers a significant area around the player, but then far off triggers would also end up getting triggered prematurely.

Edit: I'd also be perfectly happy if there was a way to have two box colliders on the player - one that causes hotspots to become interactable, and the other that starts off triggers.

Comments

  • The rest which are outside the bounds are highlighted successfully but can't be clicked on. Is this by design, or is this supposed to not happen?

    No, this is not by design - see, for example, either of the demo games. Are any custom scripts involved? Let's see your Settings Manager and Player Inspector in full.

    AC and Unity versions as always, please.

    To isolate the problem, drop the 2D Demo game's Player prefab, Brain 2D, into your scene. Are all Hotspots then interactable? Separately, drop your own Player prefab into the scene, but assign the 2D Demo's Settings Manager - what then?

    I'd also be perfectly happy if there was a way to have two box colliders on the player - one that causes hotspots to become interactable, and the other that starts off triggers.

    Though one for Hotspots shouldn't be necessary in this case, for completeness this should be possible by placing your Hotspot Detector on a new layer, and configuring your Physics settings to that this layer ignores collisions with that on which your Triggers are placed.

  • Unity: 2017.2.0f3
    AC: 1.66.1

    Either replacing the player with Brain 2D or switching out the Settings manager with the 2D demo's manager - both of these fix the issue. I also noticed the Brain 2D_SUC player prefab doesn't seem to have a Detect Hotspots component, OR a 2D box collider with "is trigger?" checked. I'm not sure if this is something I should replicate for my own character?

    Settings manager:

    Player inspector:

    Parent-

    Child-

  • Also noticed that Close interactions with - When cursor leaves menu doesn't seem to work (the settings are the same as before.) I'm using a Unity UI interaction menu set to Screen Space Overlay, is it maybe because of that? Maybe I should disable the raycaster on the parent canvas?

  • "Also noticed that Close interactions with - When cursor leaves menu doesn't seem to work... "

    Not sure why, but swapping out the game's menu manager with demo 2d's manager and then reinstating my original manager seems to have fixed both the above mentioned issues. For now, this works perfectly. I'll let you know if anything else comes up with this! :)

  • edited February 2019

    Alright, there is another issue, this may be by design. I've chosen close interactions with as cursor leaves menu or hotspot. This works well, except when the hotspot's box collider 2d is smaller than the size of the interaction menu that opens up on clicking the hotspot.

    Because in this case, when I move the cursor to select one of the options on the interaction wheel, the cursor exits the bounds of the hotspot and the menu closes. I think this should not happen, as the cursor has left the hotspot but it still hasn't left the menu, and so it shouldn't close. It seems the closing action seems to prioritize leaving the bounds of hotspot instead of checking if the cursor has left both hotspot and menu as well. Here's a video (when trying to interact with the photograph on the nightstand. The hotspots size = photo's dimensions)

  • Since you're using a Unity UI-based Interaction menu, AC relies on the "RectTransform boundary" to determine whether or not the mouse is over it or not.

    What is the size of this boundary when the UI has finished animating on? Does it fully cover the icons?

  • Ah, it doesn't. I've fixed it to fully cover the icons now, thanks!

  • edited February 2019

    The rest which are outside the bounds are highlighted successfully but can't be clicked on. Is this by design, or is this supposed to not happen?

    So I had originally solved this issue by removing the hotspot detector + box collider 2d from the player, as they were not required since I was using detect hotspot by mouse over method.

    Now, I want to support both mouse and controller. These are selected in game, and the switch works fine thanks to a custom script that 1. Changes input mode to mouse and keyboard + changes detection mode to mouse over or 2. Changes input mode to controller + changes detection mode to player vicinity and locks the cursor.

    For the controller, I have now added in the hotspot detector + box collider again, which has brought up the above issue again. If using the mouse input method, I'm unable to interact with hotspots outside the box colliders area - they can only be highlighted (settings and info are same as in earlier post)
    I can solve this issue by expanding the box collider to cover the visible area in all scenes, but then this makes the controller method cumbersome. (Partly due to reasons specified here - https://adventurecreator.org/forum/discussion/8529/is-it-possible-to-edit-the-order-that-hotspots-are-highlighted-when-using-cyclehotspot-input/p1?new=1
    Sorry for making two threads, by mistake)

    In this case, every hotspot needs to be selected by cycling through available hotspots in a scene, which is a bit cumbersome. I want it to be so that hotspots are highlighted as the player walks past them. For this, reducing the box collider to only envelope the player works best, and if there are two hotspots within this small area, then the player can cycle through the two of those. Otherwise, walking past objects highlights them (as detected by the small box collider)

    This is where the hotspots being unclickable outside the colliders bounds becomes an issue. Any ideas?

  • PM me your Managers and player asset files (prefab, animation, sprites etc) in a .unitypackage file. I'll attempt a recreation.

  • Alright, will do so soon, thanks

  • Hi, sent you a PM!

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.