Can someone tell me how to create weapons that do different amounts of damage per weapon or bullet (whichever works best)?
You can apply a damage type, along with the regular scalar value of damage. The damage type can, say, use that regular scalar value as a percentage of damage (call a function on the damage type) and then the remainder of the damage logic can use the “massaged” value from the damage type.
That way you write logic to give headshots a damage value of 1.2, torso might be 1.0, and limb shots might be .8 - the individual gun/bullet would use it’s own damage type (class - which can be data-only), and the business logic only deals with the final value of damage.
Just one way =D
I’m sorry, I don’t really understand what any of that really means, I’m pretty new to UE4. I know there is a damage function but I wanted to use my own to learn how to do it.
Create a base weapon class and give it some default values. Damage, fire rate etc…
Create a child class based on this weapon and fill its values. If you’re doing hitscan (line traces as bullets), then you can just do a line trace and apply the damage value from the weapon. If you’re firing projectiles, then you’re going to need to pass the damage value from the weapon to the projectile as you spawn it.
If you need more help i can go a little deeper, but this should be a good start for you to learn how that all works. ImmutableLambda talked about DamageTypes, that’s something that can help you with this out of the box, but I don’t think thats what you were asking. They are very useful full… for example, you could have a FireDamage type, WaterDamage etc. and these could all adjust the damage in some way.
Would creating a base bullet actor with the damage variable and making a child of itself for each weapon (for example the AK-47 would have a custom bullet to go with it), then setting a class variable for it work too?
yep, it worked!