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!
Proximity Selector Priority (UI)
Re: Proximity Selector Priority (UI)
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.
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.
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Proximity Selector Priority (UI)
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.
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.
Re: Proximity Selector Priority (UI)
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);.
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Proximity Selector Priority (UI)
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.
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);
}
}
}
}
Re: Proximity Selector Priority (UI)
Glad to help!