Can I do a dynamic cast?

So I’m currently trying to make a very basic weapon system and I made an attack dummy to make the first target/ hittable thing but I have a bit of an issue, what I’m doing now is having the dummy do ‘on collision’ and then get a cast to my bonk stick and getting it’s damage values, but now I’m thinking this system is fundamentally flawed since whenever ANY object overlaps with it, it will deal it damage and furthermore when ANY weapon hits the dummy it will always only use the bonk stick’s stats.

So is there a way to get a dynamic cast to the thing that is overlapping it rather than explicitly stating what we’re getting a cast of in the blueprint?

1 Like

Perhaps it should be the other way round - it’s the Bonk Stick that deals damage:

When it comes to filtering what we can / cannot hit, there are too many options:

  • don’t implement damage event in the actor that cannot be damaged
  • collision channels / object types - the most efficient way but may not be suitable / clash with the desired combat mechanics
  • cast Other Actor to Base Enemy Class; cast fails => do not bother dealing damage
  • query Other Actor for an interface; no interface => do not bother dealing damage
  • have Damage Type pre-process damage and decide what to spit out (that option is most useful when things start getting convoluted)
1 Like

I don’t fully follow, are you saying I should have a function inside the bonk stick that deals damage on hit rather than processing the damage in the target? that makes sense but then won’t I still need to get a cast to the bonk stick in the target’s blueprint to apply the damage anyway? That doesn’t really solve the problem since it still means I need to get a cast to a specific object

you send the damage via the weapon and process the damage on the target, you do this via the ApplyDamage/AnyDamage interface functions, or create your own. So no casting is required

1 Like

ah thank you, I wasn’t too sure what the damage functions did but I’ll do some research on it!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.