Forum rules - please read before posting.

Placing hotspot icon over NPC head

Hi, I'm trying to display a talk icon over my NPCs' heads before interacting with them (using direct movement and hotspot detection) to show the player that they can interact with them. I started by editing the Hotspot menu that used to display their names in a similar manner but not quite over their heads, deleted the label and added a graphic instead for the icon. I chose On Hotspot as the Appear type, and On Hotspot as the Position, using the Y offset to place it over the NPC head, which did work, but since my NPCs have different sizes, the position was wrong for the rest of them (also, I haven't made objects yet, but I will, and I imagine this would affect them as well), so I read in the manual that in this case I could define a Speech menu placement child to do this, although I'm not sure if this only applies for speech or if it can be used for this as well, for instance if i wanted to do this with other hotspots that aren't characters like objects. So, I made an empty object as a child of the character (image) and used its transform component to choose the placement, and then set that as the Speech menu placement child (image). Then, I set the Hotspot menu's position to Above speaking character (image), but then when clicking play and going near the character, the icon is displayed in the upper left corner of the screen (image).

Is there any way of doing what I'm trying to do? Even if it's not like I was trying, as I'm not sure if it's only intended for speech (it does say speaking character, but I tried anyway). Thanks in advance

Comments

  • You're on the right track - but keep the Menu's Position type as On Hotspot.

    Rather than setting a Y-offset in the Menu, assign an empty child to the Hotspot's Centre-point (override) field. This can then be used to override the position of the Menu.

  • Thanks Chris! That worked perfectly

  • Hi Chris, I was wondering if this also works when using Unity UI, as I was going to change the menu but ran into some problems, I switched to Unity UI, made a canvas with the hotspot icon as an image in the middle and set this canvas in the menu. Everything else I kept pretty much the same, including On Hotspot for both Position type and Appear Type, but now it's just appearing in the middle of the screen when being near a hotspot instead of over their heads (where the centre-point is), I guess it's because the canvas used as a prefab has the icon right in the middle as well, but I'm not sure how to place it so that this doesn't happen. How can I make it behave like the AC one? That one was working perfectly, it's just that I need to change the sort order of the menu and all my other menus are using Unity UI.

  • AC repositions UI-based Menus by affecting the assigned "RectTransform boundary". This is typically an immediate child of the Canvas, which itself is a parent of the rest of the UI, and is shaped such that it spans the visible elements.

    Assigning this in the Menu's properties will then have AC update its position. You can see the default UI prefabs (e.g. HotspotUI) for a guided example.

  • edited November 2024

    Ohh okay, I see, I hadn't set the boundary element as parent and that worked, thank you! Also another question regarding the hotspot icons, I'm trying to change the icon based on the type of hotspot (character, objects, doors), I'm aware this is usually done with the cursor manager, but as I'm placing the icons this way, I thought it might be better to just stick with what I have, if you think it would work better with the cursor manager I can look into it, although I'm not sure if I can place the icons over the hotspots that way. Anyways, I was thinking of switching the graphic in the menu by running an action list when the menu is turned on (when the hotspot is detected) and in that action list checking the "type" of hotspot, but when choosing the "check selected" action it only gives the option of specific hotspot. Is there a way to check if it's a character or not? Or even better, give a string or tag or something like that to each hotspot so I can check that as the "type" and switch the graphic accordingly? (I guess via script, I'm not sure though if it's possible in the first place, or if it's the best way to go)

  • What's your Interaction method?

    You should be able to achieve this with use of the "Interaction" element type in your Menu, which can be used to show the icons associated with a given Hotspot. If your NPCs have a "Talk" interaction that has an associated icon listed in the Cursor Manager, that can be displayed in the Interaction element automatically.

  • edited November 2024

    It's Context sensitive, but sorry, I'm not exactly sure how to achieve it the way you're describing. I was looking at the interaction menu but everything is in relation to the cursor, and it's a list of icons, so I'm not sure how to do this with the interaction menu, could you elaborate a bit further please?
    Just to be clear I'll add a list of the qualities I need for this icon/menu:

    • Icon should appear on hotspot, at the position of the center override element I added
    • Menu has to be Unity UI
    • Movement is direct, with hotspot detection, so the icon is just to show that you can interact with something, it's not interactive itself
    • The icon should change based on the type of interaction / hotspot
      Also, I'll include here some pictures of the previous hotspot icon menu I was using, that worked well for positioning but with 1 icon only.
      I'm trying to make something like the icons in Night In the Woods or Mutazione, the eye icon, talk icon, etc that appears over the thing we're interacting with.
  • Also even though the positioning worked well with the 1 icon method, appearing correctly over the hotspot like I originally wanted, I realized that when changing the screen size from fullhd to for example 4k, everything scales correctly, as I set up the canvases to scale, but there are 2 things that don't work properly: the positioning of the hotspot icon and the conversations (the options do appear where they have to, but I can't click them or the clickable area moved). This also applies to when I tried making a build of the game for web (in order to upload a prototype to itch.io), again both of those things don't behave like they should. Any ideas on why this could be?

  • Also, I'll include here some pictures of the previous hotspot icon menu I was using, that worked well for positioning but with 1 icon only.

    Use an Interaction element instead, uncheck For fixed icon? and set Maximum # of icons to 1. That should have it display the first-found Use interaction for a given Hotspot. Stick with AC as the Source first, and then switch over to Unity UI once you've got the icon showing as intended.

    as I set up the canvases to scale, but there are 2 things that don't work properly: the positioning of the hotspot icon and the conversations (the options do appear where they have to, but I can't click them or the clickable area moved)

    Could you share comparison screenshots showing how things look when it works vs doesn't work?

    Are you enforcing an aspect ratio in the Settings Manager?

  • edited November 2024

    Use an Interaction element instead, uncheck For fixed icon? and set Maximum # of icons to 1. That should have it display the first-found Use interaction for a given Hotspot. Stick with AC as the Source first, and then switch over to Unity UI once you've got the icon showing as intended.

    Okay so I made the new menu with AC for now and using 1 interaction element as the icon, when leaving "For fixed icon?" checked it works similarly as the system I had before, so it only displays the given icon. I tried unchecking it and setting the max # of icons to 1, but nothing appears on screen when approaching the hotspots. Here's pictures of the cursor manager's interaction icons and the menu I made. And here's a picture of how it looks in the game checking "for fixed icon" vs unchecking it.

  • Could you share comparison screenshots showing how things look when it works vs doesn't work?

    Are you enforcing an aspect ratio in the Settings Manager?

    Okay so here's a picture of the game choosing FullHD resolution, and here's using QHD, for example. The FulHD one is the correct one. No, I'm not enforcing an aspect ratio in the settings manager.

  • edited November 2024

    You'll need For fixed icon? to be unchecked. This may or not be down to a bug based on your settings, but if so: open up AC's MenuInteraction script and replace the following (around line 803):

    if (!KickStarter.settingsManager.autoHideInteractionIcons || !Application.isPlaying)
    

    with:

    if (true)
    

    Does that resolve it?

    Okay so here's a picture of the game choosing FullHD resolution, and here's using QHD, for example. The FulHD one is the correct one. No, I'm not enforcing an aspect ratio in the settings manager.

    Does the AC menu appear correct with both resolutions?

    If no aspect ratio is enforced, then this is typically a case of configuring the Unity UI component (Canvas, Canvas Scaler etc). I can't be sure of the cause from the description alone, but you're welcome to PM me the Menu Manager + UI prefab and I'll take a look on my end.

  • Hi, I changed the script line and that made the icon appear, so now it's working pretty much exactly like it was before, but it's not changing the icons, it's always the default one, even though the interactions in each hotspot are set to "look at" or "talk to". For example here's an npc's interaction, that looks like this in game, which is the icon for 'other interaction', not 'talk to', as set here.

  • Does the AC menu appear correct with both resolutions?

    If by that you mean the new menu I made using the interaction element but using AC, then no, it's the same as the other one, the icons move from where they should be, and I can't really show you the problem with the conversation menu as it's displayed correctly, but it's the interaction itself like clicking with the cursor that's not working properly.
    And thank you, I'll PM you.

  • Hi Chris, so I updated AC to the new version but it's still not working for me. Is there an extra step I have to do so the icon changes?

  • If you use Context Sensitive interactions, an Interaction element in your Hotspot menu with "Fixed icon?" unchecked should do it - is this what you have?

  • Yes, that's what I have, here are images of the menus. And here is an example of how a hotspot interaction is set up to "look at", but it's showing the "other interactions" icon instead.

  • Would you be able to PM me your project once more? Apologies for the hassle.

  • I have fixed a related issue in v1.82.1 - give it a try and see if this is now resolved.

  • edited November 2024

    Yay it works now! Thank you so much!

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.