I’m setting up a system for A.O.E. effects starting with a simple over time damage one. To do this I need to pull the health variable which is an int sitting on any actor tagged as a valid target. The issue is there are a lot of different classes that might be valid targets. I don’t want to set up a cast for every individual possible class. Is there a way to search for and grab a variable off an object without knowing its class?
Look into gameplay tags as an option.
if you want your own system then actor and component tags can work no matter the class.
Another option to try along side using tags is to use a bas class for all your units containing all the shared variables and code ie. health/armour etc etc
Then you would only have to cast to the base class.
IE for an RTS:
Class “Unit” has all the shared base vars and code
Class “FootUnit” extends “Unit” with anything soldier relevant
Class “VehicleUnit” extends “Unit” with vehicle extras
and so on, That means the same health variable exists no matter what type of unit you hit.
Also you could create an interface. You hit various units with your aoe that you detect. Then send them a message through an interface to say the type of damage, amount etc anything relevant.
The individual units then process this hit themselves based on their own stats and the hit stats.
Thanks, never played with sub classes but seems like this will work and let me dodge diving into C++!
You can easily do this with Blue Print Interfaces (BPI).
Create a BPI. Add a Function that outputs the data you want.
For each actor you want to get data from Add the Interface.
In the same actor double click on the interface function. This will open the function so you can add logic.
Drag your variables in and pipe them up.
Next open the Class that will Request the data (Character/Controller etc). Create a new MACRO.
To use it simple call the macro and pass it an Actor class reference. Such as Hit/Overlapped Actor ref.
Thnaks! This has untagled the spaghetti that my BPs were rapidly becoming!
Nice one, I did briefly mention interfaces but you spent the time with a good example!
good luck, maybe a mix of all 3 may help you with many many other scenarios!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.