Hi there, relatively new to using blueprints, and was wondering how to make it so that I gain mana (energy) on a melee hit, as opposed to just gaining it just by pressing the melee action?
if anyone could help me that would be most appreciated.
Hi there, relatively new to using blueprints, and was wondering how to make it so that I gain mana (energy) on a melee hit, as opposed to just gaining it just by pressing the melee action?
if anyone could help me that would be most appreciated.
you could do a LineTraceByChannel from the attacking Actor, into his forward Vector * Melee Distance.
Checking the Hit Result Bool, if anything got hit… Break the Hit Result Struct and cast the Other Actor for your enemy Actor Class. If the cast isn’t failing, your attacking actor could gain mana.
That would be the cheap Variant of doing it.
The more complex is, that you create Weapon BPs, that have a Weapon Mesh and a hitbox (Cube/Sphere Collider) as Component.
Add an OnBeginOverlap Event to this weapon Actor. In the Event, get the Owner (GetOwner) and cast it to your player Character. if it is not failing, let him gain mana (you need to add a GainMana Function or Event in the PlayerCharacter).
Or, if it fails… Cast to an enemy actor. If it is not failing, let the enemy gain mama.
Attach this weapon to your player or enemy.
I would suggest to first learn the basics about BPs, before starting complex Systems…
So… Do the cheap one first ![]()