Proximity Selector Priority (UI)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Proximity Selector Priority (UI)

Post by cptscrimshaw »

Hi Tony,

I have a subclass of ProximitySelector that accounts for priority when choosing which usable to use when you hit the button, but I'm having trouble getting the correct UI to show. For example, if I walk up to two objects that both have usables, it will choose the correct one when I hit the button, but the UI is showing text for another one. I was trying to override the SetCurrentUsable method, but running into troubles. Is this something you've accounted for before?

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

Re: Proximity Selector Priority (UI)

Post by Tony Li »

Hi,

In your overridden class, call CheckTriggerEnter(GameObject) to set the usable. This will make it act like the usable just entered the Proximity Selector and should be made the current usable.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Proximity Selector Priority (UI)

Post by cptscrimshaw »

Hi Tony,

Thanks - let me try to explain a bit further. My current overridden class is for UseCurrentSelection(), so that only gets called when the player presses the button to activate the usable. I'd like to be able to update the ProximitySelector on trigger enter and check the priority of all usablesinrange and show the one with the highest priority.
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Proximity Selector Priority (UI)

Post by Tony Li »

What about just overriding the CheckTriggerEnter() method then? If the usable that's passed to CheckTriggerEnter() is higher priority than the current usable, call base.CheckTriggerEnter(); otherwise add it (usablesInRange.Add(usable);) but don't call OnSelectedUsableObject(usable);.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Proximity Selector Priority (UI)

Post by cptscrimshaw »

Thanks Tony!

That worked, but I did have to add a check to make sure that currentUsable wasn't null. And adding the usable didn't seem to matter, though I haven't tested it a ton.

Code: Select all

        protected override void CheckTriggerEnter(GameObject other)
        {
            if(other.GetComponent<UsableES>() != null)
            {
                if(currentUsable == null)
                {
                    base.CheckTriggerEnter(other);
                }
                else
                {
                    if(other.GetComponent<UsableES>().priority > currentUsable.GetComponent<UsableES>().priority)
                    {
                        base.CheckTriggerEnter(other);
                    }
                }
            }
        }
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Proximity Selector Priority (UI)

Post by Tony Li »

Glad to help!
Post Reply