Jsou mé časovače efektivní?

Hi there, yeah using a timer for each enemy can work, but you are right it’s not the most efficient approach, especially if you have a large number of enemies. Managing numerous timers can become resource-intensive. Instead, personally I would use a more efficient method of centralized or global timer that loops over all enemies and applies the poison effect as you mentioned. This approach reduces the overhead of maintaining multiple timers and can lead to better performance.

Centralized Timer Approach

Here’s how you can implement a centralized timer to manage the poison effect for all enemies:

  1. Create a Central Manager:
  • Create an Actor blueprint that will act as the poison effect manager, e.g., BP_PoisonEffectManager.
  1. Store References to Enemies:
  • In BP_PoisonEffectManager, store references to all enemies that need the poison effect applied. You can do this using an array.
  1. Implement a Central Timer:
  • Use a single timer in the manager to loop through the array of enemies and apply the poison effect.
  1. Apply Poison Effect:
  • In each enemy blueprint, implement the logic to handle the poison effect, such as reducing health over time.

Hope this helps.