Show Sprite with Proximity Selector

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Show Sprite with Proximity Selector

Post by Mackerel_Sky »

Hi Tony,

This seems like a pretty easy question but i'm having trouble getting it to work.

Essentially I need an icon to show up when the player can interact with NPCs or world objects, like this:

Image

There are two different sprites depending on if the player is talking to an NPC or examining a world object (most world objects will trigger a conversation, like that computer thing I had problems with, some will not), plus one more that is triggered outside of the DIalogue System where the player is picking up items.

I searched for a bit around the forums and I think I need to play around with the standard UI selector elements component. I can't seem to figure out how to modify it, though. I don't need any of the yellow text or anything, just the icon to appear.

Do you know how I would go around implementing this? Should this even be something I should handle with Dialogue System, or should I just compare tags on collision or something?

Thanks for your help!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show Sprite with Proximity Selector

Post by Tony Li »

Hi,

You might as well use the Dialogue System for this since the functionality is built in. Here's an example scene:

DS_ProximitySelectorExamples_2020-04-16.unitypackage

It looks like this:

DS_2DProximitySelectorExample.png
DS_2DProximitySelectorExample.png (24.31 KiB) Viewed 1188 times

A note in the scene explains how it's set up:

1. I disabled the Dialogue Manager's Instantiate Prefabs since we don't need its default selector UI or quest UI stuff. You could just remove the Basic Standard UI Selector Elements from it if you prefer, or just leave it.

2. The Harp is on the "Water" layer to distinguish it from the others without having to define new layers in the project.

3. The Player's Selector Use Standard UI Elements shows one UI for Usables on the Default layer, another for Usables on the Water layer. Layers are a handy way to specify which selector UI (icon) to use. You could use tags instead. The Selector Use Standard UI Elements component has options for both.

4. The Tree has its own Usable UI that only appears when you select the Tree. Its Usable's OnUse() event does something non-Dialogue System related. It activates a child GameObject.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Show Sprite with Proximity Selector

Post by Mackerel_Sky »

Hey Tony,

Couple of weird things happening when I try to implement your solution.

1. The NPC image(first in list) appears when I begin the scene. It disappears when I walk past an NPC and it detriggers.

2. The first time I start a conversation, the dialogue UI appears for a split second and then is replaced(?) by another one. After that dialogue runs as normal.

Any ideas?

Thanks
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show Sprite with Proximity Selector

Post by Tony Li »

Mackerel_Sky wrote: Fri Apr 17, 2020 4:47 am1. The NPC image(first in list) appears when I begin the scene. It disappears when I walk past an NPC and it detriggers.
You can set it inactive so that it starts hidden.
Mackerel_Sky wrote: Fri Apr 17, 2020 4:47 am2. The first time I start a conversation, the dialogue UI appears for a split second and then is replaced(?) by another one. After that dialogue runs as normal.
Does it look like it's replaced by the same type of dialogue UI? Or is it a different style dialogue UI?

If it looks like it's replaced by the same type of dialogue UI, it's probably the animator. As a test, try removing the Animator components from your dialogue UI's Dialogue Panel and subtitle panels. Retain a copy of your original dialogue UI with the Animators so you can get it back easily. If that gets rid of the split-second flash, let me know and we'll look at the animator setup. If it doesn't, make sure the main dialogue UI GameObject (the one with StandardDialogueUI) is active. This GameObject takes care of hiding all dialogue UI panels at start.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Show Sprite with Proximity Selector

Post by Mackerel_Sky »

Hey Tony,

Disabling the image fixed the popup, thanks.

I couldn't find the Animator for the subtitle panel, but I disabled it on the Dialogue Panel and it fixed the popup, so I think it's the first case.

Thanks
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show Sprite with Proximity Selector

Post by Tony Li »

If you end up wanting the animations back, keep an Animator window open on the Dialogue Panel and see what states it's in. It may just be an issue of adjusting the animator controller you're using. Also, there were some improvements to the way animation is handled in recent DS versions. If you're not on the latest, you can consider updating.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Show Sprite with Proximity Selector

Post by Mackerel_Sky »

I think I caught the issue.

For some reason when the Selector Use Standard GUI Elements component is enabled, the Dialogue Manager doesn't instantiate the canvas with the Dialogue UI on it. When I trigger a conversation, the canvas is instantiated but the dialogue panel triggers Hide a split second as it's loaded for some reason.

Do you know what's causing this?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show Sprite with Proximity Selector

Post by Tony Li »

If I understand you correctly, it sounds like it's instantiating the dialogue UI at the first point of use. Try ticking the Dialogue Manager's Other Settings > Preload Resources to make it instantiate the dialogue UI when the scene starts.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Show Sprite with Proximity Selector

Post by Mackerel_Sky »

Hey Tony,

Preloading the UI fixed the issue.

Thanks!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show Sprite with Proximity Selector

Post by Tony Li »

Glad to help!
Post Reply