How to disable to Use Items when Damage Visualization is on

Gubernator

New member
I have simple question for you.
How to disable AI to use Items (like shoot Pistol), when he get damage -> Damage Visualization is Actice.
 
If your AI is using a Health/CharacterHealth component, you could use the "On Damage" event - e.g. add a simple script to that event which would enable a state on the agent, then you can use state presets to disable the Use abilities on the agent. To set a state from a script you simply need to do something like:

Code:
StateManager.SetState(theCharacterGameObject, "MyState", true);

Then have a state preset on the agent's Use abilities, set the state name to "MyState" and add the "enabled" property to be set to false for that preset.
 
Thanks, that's work!

But one more question:
How to "enable" again this property(Use) on "MyState", after Damage Visualization is complete.
 
You would need to simply disable "MyState" again:

C#:
StateManager.SetState(theCharacterGameObject, "MyState", false);

I misunderstood what you were asking though, if you want this to happen specifically based on the Damage Visualization ability then you don't even need to use any script. You can simply use the state name set on the Damage Visualization ability. E.g. in the demo, the Damage Visualization ability actiavtes the state "Take Damage", so you would just use this state as your name for the preset on the Use abilities (instead of "MyState").

1626856419776.png
 
Top