Interact Ability Message for interact Ability added in Runtime

nathanj

Active member
Hi,

Working with the UMA integration and am stuck on something. If I use the UMA Ability Builder to add an Interact ability to my player in runtime the Ability Message does not appear. I've tried making my own Interact ability that assigns a value to the m_AbilityMessageText in awake and in the editor this looks fine but the UI message does not appear, it's the same as the default Interact.
If I build the bones for the UMA character and set up the Avatar in a more normal way and assign an Interact ability and leave the Ability Message Text field in the Interact editor of the Locomotion component I get the same behaviour, no UI Message prompt. However, if I add text to that field before pressing play then the UI message behaviour works as expected.
Is there a way I can assign a value to m_AbilityMessageText for my custom ability so it is set before Awake?
I've had this issue before and have had to fidge it by putting a space in the text field for the Interact Ability so it would display messages but with an Ability added at runtime I'm lost.

Thanks in advance,
Nathan
 
The way I achieve runtime m_AbilityMessageText change, in to do it within ValidateObject() after the checks, like so...
C#:
 protected override bool ValidateObject(GameObject obj, RaycastHit? raycastHit)
        {
            if (!base.ValidateObject(obj, raycastHit))
                return false;

            m_BoardSource = obj.GetCachedParentComponent<IBoardSource>();
            if (m_BoardSource == null)
                return false;
            m_AbilityMessageText = "Press 'Action' button to board " + m_BoardSource.HintDisplayName;
            return true;
        }
 
Ah, wait, that is fine for changing the text in runtime, but the issue I am having is that Ability Message Text field is null on awake then it never displays text. I can change it all I want after that but it will never display.

What I need to do is if assign a string value of any kind to the Ability Message Text field when the ability is added to the player. Or, @Justin could this be a bug? I feel like its not exactly a desire behaviour.
 
It only enables if I have something loaded in the ability message text field before. If I add that after the Messages UI doesn't open.
 
I have not had much to do with UMA so I have no idea how the UMA Ability builder works, but you could possibly set it when the ability is added by accessing and modifying the Serialized property via editor script
 
I’ve had the same behaviour with the default Interact Ability when it was null on start. I used to just put a space in the field so it wasn’t null because I could then dynamically change it. But now that I don’t have that option I’m a bit stuck.

I’ll have a look to see if there is an editor script that will allow me to change it, thanks for the suggestion.
 
The AbilityMessageText is used within the AbilityMonitor when an ability may be able to be started, so you need to make sure that text is assigned before that check. This is done within the OnAbilityCanStart callback if you want to debug it.
 
Sorry to keep on about this but I haven't been able to work this out.

Its simple enough to replicate. Add a new Interact ability to a character and leave the AbilityMessageText blank. If you press play and then add text to the field the MessageMonitor will never trigger for it. You can still interact with objects and click on them, you just don't get the UI prompt that the ability is able to be started. If you add a space or any text to the field and then press start the MessageMonitor will display correctly and the text can then be changed dynamically, but again, only if the field is not null on start.

Is there any way around this? I have been trying to look through the code and figure out what where this original check might be. I suspect that it is getting a reference when the ability is initiated but it doesn't recognise that it has changed, it just keeps a reference that it is null.
 
@Justin

So the problem is that m_CheckForAbilityMessage is the bool that determines if the message is null or not. If it is null on initialize then m_CheckForAbilityMessage is set to false and the ability message is permanently blocked from diplaying.

If I change line 289 of the Ability code, in the Initalize method, from
Code:
 m_CheckForAbilityMessage = !string.IsNullOrEmpty(m_AbilityMessageText) || m_AbilityMessageIcon != null;
to
Code:
 m_CheckForAbilityMessage = true;
I can then instantiate the Interact ablity in runtime, change it dynamically and have it display a message when an interactable target is selected.

Is there any chance you could change the Ability script to allow the CheckForAbilityMessage bool to be Set, or make m_CheckForAbilityMessage public?

Thank you,
Nathan
 
CheckForAbilityMessage is set within Initialize, but it's also set within the AbilityMessageText property. The inspector doesn't set the property, but for your own script if you set the property instead of the field it should work.
 
Top