What is the best way to create a health system?
Hi, I want to make a basic health system in my project. In this system I want to be able to damage barrels (Actors), robots (Pawn) and Humans (Characters). Now I would like to have just one damage function and one health variable I have to access.
First I tried just to make a parent child system. But the problem is, that if I inherit from AActor, I can't use any Pawn and character classes. If I inherit from APawn or ACharacter, I can't use the base AActor class anymore.
I could rewrite the AActor class, but I don't think that is a good idea, because all other classes use these codes. Plus my engine breaks when I try that.
Next I tried to make the functions in the controller. But first, actors don't have any AiControllers and second you would have to rewrite the function in the player controller.
My last idea were interfaces, but in the interfaces I can't set any timers (like the time delation from dispawning after the Actor dies. Plus I can't access GerWorld(), because that's an AActor function and not Interface. So I can't cast to the MainPlayerController.
With this I don't know any other easy ways to create a health system. Thx for the help!
asked Sep 03 '18 at 05:25 PM in C++ Programming
This is usually done using interfaces.
Interface methods must be overridden (implemented) in all objects that inherit the interface so you can access all needed functions while implementing the interface in the objects.
Follow this question
Once you sign in you will be able to subscribe for any updates here