How to setup
Last updated
Last updated
The actor must:
Include the SignificanceTrait
which includes numerous settings to setup your agent
Implement the I_MassSignificance
interface.
Once added, you fill in the settings and then in code, you update everything related to the settings you assigned through the functions provided by the I_MassSignificance
interface.
In this example, I've made a health bar that shows up when the significance of the actor follows these requirements:
This setup is fairly simple. This agents significance is tracking its LOS, distance from the center of the screen (dot product) and distance from the player pawn.
The above code is triggered every time the agents significance is updated (this is triggered on the game thread).
If the agent leaves the designated ranges, the NewValue
will return -1
The last branch will return true if the player has LOS and if the player is either in within the designated range of the agent, or if they are near enough to the center of the screen.
Limit the update frequency. Depending on the code you're updating, it's rare that people will notice anything less than 30 ticks per second.
Limit logical gameplay code whenever possible. For example, agents that might have ambient dialogue shouldn't trigger when the player is not within hearing distance of them.
If the engine already provides a built-in solution for disabling tick or something similar, use that instead. For example, animation blueprints have features to disable themselves when the actor isn't rendered.
If the significance evaluation is spawning something (like in this case, we're spawning a health bar) combine it with a pooling system for maximum performance. I personally use my pooling system; .