Hi there. Just a quick problem I’ve got here.
I’m trying to make a crowbar that will apply damage to my breakable crate blueprint when you have the crowbar in your hand. The images show what I currently have. The first image is from my character class where I am saying if the crowbar is currently held, set my attacking boolean to true. This bit works fine. Then in my BP for the breakable box, I have a collision box and I say when I collide with that, if I’m attacking (clicked left mouse) then take damage. The issue I’m having is that for some reason the take damage event only occurs if I am holding down the left mouse button before I enter the collision box. and I cannot click again to apply damage again. I can’t figure out what’s causing this. I want it so that when I am within the range of the collision, I can left click and apply damage to the crate. So I could left click several times to destroy it.
I’m sure this may be a simplistic fix, but I seem to be really struggling working it out, so any help would be much appreciated. Thanks.
Um, thanks for the reply mate, but I’m not really sure how I can apply that to my project. I don’t want different damage types. The crowbar is a skeletal mesh and while it’s equipped I just want to be able to click in the box collision area to do damage to that asset. In other words, is there a way I can apply this with my current version and just change the begin overlap to some other event? And if so, what sort of event?
1 and 2 simply change the Damage Type (weapon switching basicly) you have to create those Types based of DamageType. Everything else is self explaining I hope.
If you wonder why your Logic does not work is because Begin Overlap happens only once everytime you Enter and thats the only place where you execute your logic.
I think you missunderstood why I used the Damage Type its just a way to Filter out what the Incoming Damage is. Its a bit more foolproof for your Future development in case you add more Weapons (or Explosions, Enviromental stuff, not limited to Weapons) were some can Break the Crate and others can´t. You could name it Blunt Damage and apply it to many Weapons. With you approach you couple your Code and if you add things you have to change many things around etc. it gets confusing really fast. And its not hard to implement, instead of setting the bool you simple set the Damage type and you are done.
Anyway what you want is todo a linetrace in your case. I dont know if you got a FPS or TPS or whatever so your linetrace Start / End depends on your Gametype. In my Case I use Mouse position: https://i.imgur.com/h57mNrg.png
Right, so I still don’t really understand what you mean tbh. In this level I am making, the crowbar will be the only melee weapon and is only going to be used on the boxes around the map. I’ve created what you showed as best as I could in my third person character BP and my box BP. However, I have no idea where I set a current damage type and what I set that to. You can see that I created two variables on my character, one of a damage type class, as I saw you used that in your earlier comment, and an actual damage type variable “crowbarDamage”. I don’t know where I should be using the two damage types variables you have said about and what they should be set to. In the box BP, I have no idea what to cast to, because the only damage cast that comes up is just damage type. Whereas in your earlier pictures you had it going to one of your own damage types. Yet that’s not available for me.
I just need to know the simplest way of doing this but while keeping my condition stuff I showed earlier the same, because I want this attack to only be able to happen if the player is currently holding the crowbar, which I set up separately. Sorry for not understanding, but I’m still relatively new to Unreal and haven’t used a lot of this stuff before.
Simple Attack with a trace https://i.imgur.com/03Bxobr.png also set the default for Damage Type to the first equipped Weapon.
Moving on to our Crate first we create a handy reduce Health function that also gives a bit Debug info https://i.imgur.com/g9VLZ0d.png
We also setup our Current Health to max health at the Beginning and Implement the take any Damage event https://i.imgur.com/pao102J.png
The first case “Blunt Damage” I simply apply Damage as is.
In the next examples just to showcase how to handle other types of Damage there is Fire Damage that Spawns a Particle and applys Damage over Time. And the Last one does Double Damage and applys Physical Force based on the Damage causers Location (Could be a Granade, Simulation on the Crate needs to be on) https://i.imgur.com/bfStJ66.png
Simple as that and very Flexible and the best part is they work Completly independent of each other. Your Character can Hit anything and does not need to worry how the Damage gets applied and the reciving End does not Care from who or what it recives Damage and can Filter down anything you need to know.
Ooooh. It actually works now. I was implementing what you said and didn’t notice it working at first, then I realised I’d forgot to set the damage amount :D. Thanks so much for the help mate, I never really thought about using a method like this. It’s really cool that you can build on it to add extra damage types. Apologies for not really understanding at the beginning, but I think this will really help me understand now.
Thanks again mate!