Melee attack triggering proximity selector

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Melee attack triggering proximity selector

Post by chrislow19 »

Hi Tony,

I'm using a 2d trigger collider coupled to my animations for my melee combat system. These hit boxes are a child of my Player and are untagged (and on a different layer). However, they seem to trigger the proximity selector on NPCs whenever i play my melee animation and the hit box touches the usable area. I don't see a way to set a tag for using the proximity selector. Any solution to this?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Melee attack triggering proximity selector

Post by Tony Li »

Hi,

Set up the layer collision matrix so the Proximity Selector's collider only registers collisions with the NPC's Usable collider.

One way to do this is to add a new layer. Let's call it "Interaction".

Select menu item Edit > Project Settings > Physics 2D and configure the Interaction layer so it only registers collisions with itself.

On the player, move the Proximity Selector and its trigger collider to a child GameObject, and set its layer to Interaction. Set the Proximity Selector's Actor Transform to the main player GameObject.

On the NPC, move the Usable and its collider to a child GameObject, and set its layer to Interaction, too. Put your Dialogue System Triggers, etc., on this child GameObject.
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Re: Melee attack triggering proximity selector

Post by chrislow19 »

Brilliant! I would never have thought of that. Thanks once again!

One more question - where is the layer option for the dialogue bubble subtitles located? I have objects (trees) that are covering it up on a certain layer. I haven't been able to locate where to change it.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Melee attack triggering proximity selector

Post by Tony Li »

The bubble panel (e.g., Bubble Template Standard UI Subtitle Panel) has a Canvas element. You can set its Sorting Layer and/or Order In Layer.

For example, you could create a sorting layer named "UI" that's above all other sorting layers, and assign the Canvas to the "UI" layer.

Or, if you're only using the Default sorting layer for everything, you could set the Order In Layer to a value guaranteed to be higher than all other sprites' values (e.g., maybe 9999 or something like that).
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Re: Melee attack triggering proximity selector

Post by chrislow19 »

Hi Tony,

I just noticed a new problem that was lurking in the shadows following this fix, I've got a second selector popping up on top of the screen now. Only, it appears after I've initiated a conversation with an NPC, then left it's trigger range, and returned. The default selector then pops up at the top of the screen along with the proximity selector. Of note, I've completely moved all dialogue system items to another game object with the assigned layer and removed collider triggers on the main object associated with it. THe rigidbody remains on the parent object. Lastly, I did turn the new "interactable" game object with the dialogue stuff intoa prefab.
Untitled-3.jpg
Untitled-3.jpg (156.94 KiB) Viewed 1253 times
Also, I have a new warning, but it doesn't appear to be affecting anything:
Untitled-5.jpg
Untitled-5.jpg (17.03 KiB) Viewed 1253 times
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Melee attack triggering proximity selector

Post by Tony Li »

Hi Chris,

Does your scene have a Dialogue System Events component that enables/disables the Proximity Selector? If so, make sure you only have one, that you've paired disable (in the OnConversationStart() event) with enable (in the OnConversationEnd() event), and that it's enabling/disabling the right components.

You can also try getting deleting the selector display that's on the top of the screen. It might be assigned to the Dialogue Manager's Instantiate Prefabs component (in which case remove it from the list) or a child of a Canvas somewhere in your scene.

Also make sure you only have one Proximity Selector in the scene. Maybe you have one on the player and another on a child GameObject of the player.
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Re: Melee attack triggering proximity selector

Post by chrislow19 »

Thanks Tony, I had a stray proximity selector - script was disabled - but it still fixed the problem once I removed it. Odd, but thanks for the help!
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Melee attack triggering proximity selector

Post by Tony Li »

It may be that a Dialogue System Events somewhere was re-enabling it. Anyway, glad to hear it's working now!
Post Reply