Hi so it seems I’ve virtually overloaded myself with tutorials lately and I have really confused myself. I can’t seem to marry the aspects I want from certain tuts and now I am reverting to something that I hope is basic enough to gain me some help.
All I am attempting to do is create a 'Mining Node" which is a BP_Actor that I have given a static mesh (box) and a box collision. I added a variable for health. Then I added a oncomponent overlap to the collision. is what I have this far:
After that I have a pickaxe static mesh that I created a BP_Actor from. I took the pickaxe and added a sphere collision around the area I wanted to do the damage. I added a variable for damage and then added a on component hit to the collision sphere. This is what I have so far for that.
I tried a few different things but it doesn’t seem like I can figure it out and maybe I have been confused to the point I am missing something simple. My end goal is to have my character play an animmontage for his mining action and have the pickaxe_BP hit the box collision to do damage. So am I even close, lol?!?
I’d really appreciate some guidance or advice! Thanks
To effectively apply the damage (decrement health) you must add logic in the existent Damage events inside the actor: Event Any Damage, Event Point Damage or Event Radial Damage. Feel free to choose which one fits better to your gameplay.
Yes, that’s the basics. I’d also clamp health to zero or above, and then check after setting health to see if it’s 0 (branch node and the = node), then you can run your breaking logic off that (your effects, etc)
Okay thanks that helped! However this leads to another question. I can’t seem to figure out how to get my character to equip the BP_pickaxe or figure out how to call it correctly in the Character BP. I was able to damage the MiningNode with my character by walking into it collison, but my goal is to have the pick collision sphere do it. Any help would be awesome!
for equipping something , in case of skeletal meshes , you could start by creating a socket at where you want to equip it , then attaching it to that socket by using " Attach actor to component " or "Attach actor to actor " nodes .
If it is a static mesh , use a helper component like arrow at where you want to equip it , then attach it using above nodes , and you can make helper object invisible .
So I ended up adding a collision sphere to the pick just as I did above but instead I was rooted to the pick in MyChar_BP that was socketed to the R_Hand bone. (I think this is what was referring too :)) So now when my animation plays and it strikes the node it destroys it. However I have the issue now of if I walk past or turn into the node the collision on my pick will cause an overlap and destroy the actor. Any thoughts on how I might be able to just have it just apply damage when my Animmontage is called?
Try creating a boolean bIsAttacking and use it as a check before the Apply Damage. So, when you press the attack button, set the boolean to true. It will prevent you from overlapping AND cause damage. When you release the attack button, turn it back to false.
Thanks that worked. And this is my final BP although its not perfect since my collision on my pick damages whenever it overlaps instead of only when LMB, and after I do use my LMB it then removes the ability to do damage. lol
My collision issue is: When I push LMB it plays its animation and if I am in range it the sphere collision will indeed overlap what I was trying to hit and it causes the damage. But when I move in range when I have the pick drawn, the sphere collision, depending on angle can overlap and cause damage. I want that it to be active when I use LMB and the swing animation.
Oh, after seeing the video you sent to me in PM I bet your issue is that the default value of the boolean “Is Mining” is set to true… if not, there is an event that is called before that sets it to true (maybe Begin Play?).
About the Damage issue: I’ve noticed that you decrement your MineNode current health to the actual damage, I think it’s inverted.
One thing that I’ve noticed in your video is that the “Its been mined” has printed two times once you swing the pick close enough for it to start overlapping twice. It’s ok, you just need to add some nodes to prevent this. I suggest you add the DoOnce node like the image:
The Delay duration value must be your montage play duration to sync correctly.