Dynamic Casting

Hello there!

I’m working on a game, and I’ve ran into a problem:
Basicly, what I want to do is, when my projectile hits an actor, I want to cast into that actor, and get some of it’s variables like HP(float) and Name(String). Here comes the twist in the story:
I want to make it dynamicly. So if the projectile hits ActorA, then I want to get ActorA’s HP and Name, if it hits ActorB, I want to get ActorB’s variables.
Is there a way to get on a Hit event which BP-Actor the projectile hit, and cast into the Actor?

(Sorry for my terrible English)

Very easily.

From your projectile blueprint you want to add in a hit event. Then drag off the actor pin and create a “cast to” for whatever objects it is you are trying to interact with. And then from there drag the pin off the cast object and you can interact with its variables directly from the projectile, or better practice would be to trigger an event in the actor itself.

I actually did a quick example of exactly this for another user showing shooting some targets.

Kind of late, been searching for other stuff, but found this.
Interfaces is what you look for. And there is already an interface for that with preset events, like “TakeDamage” or “EventAnyDamage”. All you have is to apply that damage in projectile, without casting. You can implement your custom interface for some other functions, like “hey, whoever can do this - just do it”.