Forum rules - please read before posting.

Strange Problem With Hotspot Detection & Interactive Boundaries

Hi, I'm encountering something weird and I need help figuring it out.

For the record, I'm using unity version 2022.3.20f1, and I have the most up-to-date version of AC as of right now, which is v1.83.0.

I'm creating a 2D sidescrolling point-and-click for PC. I have several interactable objects in my scene, two doors, an npc, and an apple. Each of these things have a 'use' interaction which is different for each, and an 'examine' interaction, where the player makes a little remark. Each of these objects has an interactable boundary, and the setting for hotspot detection is set to 'mouse over'. The player uses direct movement with the arrow keys. Originally, I used paths as a way to restrict the player's movement along a line, but then switched over to using polygon colliders to restrict the character's movement to a set area instead. This works the way I'd like it to, but a weird unintended consequence since making this change is only the apple's hotspot works, for reasons I can't figure out. All of the apple's settings in the inspector are identical to the other objects in the scene. I can put the player within another object's interactable boundary, and mouse over those objects, but the name of the object does not appear over it and neither left nor right click does anything, so all I can assume is those hotspots aren't being detected at all. I tested all of these hotspots in my earlier version and they all worked before. All of the interactable objects and their hotspots are on the default layer. At first, I thought this message here was the culprit (see image) https://imgur.com/QsRCLay , since the player's circle collider 'is trigger?' setting is set to false, and its rigidbody 2D is set to Dynamic in order for the collisions to work. However, even when I reverted these settings back, the hotspots of the other objects in the scene still were not being detected, and the apple works as normal. I don't really know what to do at this point, so thank you to anyone who can help.

Comments

  • Welcome to the community, @NightlyJambles.

    Is the issue specific to those Hotspots that have Interactive Boundaries? That is, if you unset the boundary field for a given Hotspot, does it then become interactable at any time?

    At first, I thought this message here was the culprit (see image) https://imgur.com/QsRCLay , since the player's circle collider 'is trigger?' setting is set to false, and its rigidbody 2D is set to Dynamic in order for the collisions to work.

    What collisions are you dealing with? For a point-and-click game, collision is typically avoided except in special circumstances, as the Player's position is controlled by the NavMesh.

    This being a visual issue, any screenshots you can share of the scene / setup will help clarify the situation. But to check if this is an issue specific to your Player, try temporarily relying on AC's "Sample 2D Player". This can be done by re-running the New Game Wizard, choosing "Modify existing" and installing the Sample 2D Player template.

    This'll replace your own Player as the default - but you can re-assign your Player after testing in the Settings Manager. With the sample Player, though, do they have the same issue?

  • Hi Chris, thanks for the swift response.

    I've done a lot of troubleshooting since reading your reply, to no avail.
    From what I can tell, the interactable boundaries don't factor into it at all. I removed the interactive boundaries, and it changes nothing. Making the interactable boundaries larger did not change anything either. I've tried creating new scene objects with hotspots/interactions, with no interactable boundaries, and those aren't detected either. I've tried changing the layers the hotspots and the player live under (default vs ignore raycast), and that didn't change anything. I took your advice and switched to the Sample 2D Player, and he controls as he should, but he couldn't detect any hotspots in the scene at all, not even the apple. I tried changing the hotspot detection method from 'mouse over' to 'player proximity' and nothing changed. Going back to the original player I designed, I moved the hotspot detector to a child object with it's own rigidbody 2D and box collider, which feels more correct than how I had it before, but this also didn't seem to have any effect.

    As for your question about the collision, I'm using direct control via arrow keys for the player to control their character. In order to limit the playable area so the player can't walk all over the screen, I've created 2D box colliders in the scene with the playerstart inside. This works as intended, but since making this change the hotspot detection has been all messed up. Removing the box colliders from the scene and letting the player walk directly on top of the hotspots does not make them detectable still.

    I've looked over the inspector many times now to see if there's some setting that differentiates the apple from the other objects in the scene, since it's the only hotspot that works, and I still can't find anything. I really appreciate the help, because the nature of this problem is almost comical.
    Here are some screenshots:
    The playable boundary (highlighted green): https://imgur.com/a/pHNupoI
    The character in the game during play mode: https://imgur.com/Z4bkZwH
    Inspector Window of that confounding apple: https://imgur.com/H0htykO
    https://imgur.com/G7DaNGG
    https://imgur.com/p2zHo7H
    Inspector Window of nonfunctional door: https://imgur.com/RG8t8TU
    https://imgur.com/b24S9e9
    https://imgur.com/iO5NZjQ

  • Going back to the original player I designed, I moved the hotspot detector to a child object with it's own rigidbody 2D and box collider, which feels more correct than how I had it before, but this also didn't seem to have any effect.

    To clarify: the Hotspot detector is only relied upon if your Hotspot detection method is set to Player Proximity, as its collider will be used to detect Hotspots within it. When set to Mouse Over, this object is ignored (and can be removed if desired).

    The Rigidbody can also be removed if you set your Interactive Boundary Detection method fields to Transform Position. This will cause them to examine the Player's root position as it enters/exits their boundary.

    I'm using direct control via arrow keys for the player to control their character. In order to limit the playable area so the player can't walk all over the screen, I've created 2D box colliders in the scene with the playerstart inside.

    If the 2D NavMesh describes the area that the Player can move around, surrounding colliders aren't necessary - you can check Auto-stick to NavMesh? in the Player's Inspector to keep them bound to the NavMesh.

    I've looked over the inspector many times now to see if there's some setting that differentiates the apple from the other objects in the scene, since it's the only hotspot that works,

    The screenshots don't reveal any issue - if you come out of 2D mode in the Scene window, the Hotspots are all in the same Z-plane, i.e. the same distance in front of the camera?

    If mouse-over Hotspot detection is not working on Hotspots that are on the Default layer, then it's typically due to another object blocking them - in between the camera and the mouse. Such an object can be a Collider (again, on the Default layer) in the scene, or - if you have Unity UI blocks interaction and movement? checked in the Settings Manager - a UI object that's overlaid in the same position.

    If neither of these appear to be the case, does the apple continue to be interactive if you move it, to a position similar to that of e.g. the door?

    To see if this is a scene issue vs one to do with your global settings, run the 2D Sample Scene with your own Managers/Player assigned, and see if the Exit and Floating Sphere Hotspots are interactive. You can import this scene similarly from the New Game Wizard.

  • Thanks to your insight, I've solved the issue!

    The problem was two-fold, caused by both the polygon colliders I had used to restrict the playable area, and the interactable boundaries I had put on the objects. In my troubleshooting, I had only removed one or the other, and I didn't make a correlation for what was causing the issue. When you mentioned that something between the camera and the mouse can block it, I realized that the interactable boundaries on the objects that weren't working in the scene lived in the 'default' layer instead of the 'ignore raycast' layer, preventing the mouse from 'seeing' the hotspot underneath. The multiple polygon colliders in the scene also were set to the 'default' layer, blocking any hotspots that were behind them. The reason why the apple was working, was at some point I had already set its interactable boundary to 'ignore raycast' and didn't remember, and wasn't covered by the other polygon colliders in the scene. Now that both are set to 'ignore raycast', the hotspots are visible as they should be and the colliders keep the player inside the area I want them to stay in.

    Thank you for all of your help!

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.