Greetings, I am new to Unreal Engine blueprint programming. My current project is a tower defence prototype. I hoped to learn while developing this prototype. The task I am currently struggling with is the damaged blueprint interface. The enemy has health and a function updates the floating widget but I am getting an error
Read the error messages- they help. This one effectively says “Accessed None trying to read the return value of a GetActorOfClass node.” Meaning the GetActorOfClass node couldn’t find any actor of that class.
You can click anywhere with a magnifying glass to instantly go to the site of the error.
The issue is in your Que Damage On Collision, assuming you don’t call the bullet hit function anywhere else. You can figure out where exactly it is by clicking the magnifying glass.
You have quite a few things off here. Biggest being you’re just damaging both a random soldier and a random heavy soldier- not even the one you’ve just hit. You’re also killing the bullet after 0.5 seconds rather than immediately.
Instead of getting a random soldier and damaging it, then getting a random heavy and damaging it, followed by killing the bullet after 0.5 seconds of waiting, just have the branch, call BulletHit on the “OtherActor” from the overlap event, and immediately call DestroyActor on self.
This may make it look like you’ve broken something, but you haven’t. Notice that barely any of your tower’s bullets are hitting. As a bandaid fix, you may just want to increase their speed. Though something else definitely is broken- they’re applying damage before they’ve even overlapped anything- make sure they can only collide with enemies and not your towers.
Also there is a built-in damage system in Unreal. Not a built in health system, but built in damage. It supports types of damage (ie fire, corrosion), instigators (the bullet may have hurt you, but you care more about the person who shot the bullet), and coordinate-based damage (ie for an explosion you may want to use ApplyRadialDamageWithFalloff).
Implementing:
Thank you. I have moved the bullet damage in the “solider enemy” blueprint and to make it run off that begin overlap which worked. However, The update health widget says health widget not valid.