Getting Reference to Enemy Character

Hello,

I am having a hard time trying to figure out how to get a reference to my Enemy1 Blueprint for my damage calculation Function. I can do it normally with getting a reference to the player controller, but not to Enemy1, which I have made as a Character Blueprint. I feel like I missed something, somewhere…

Here is my graph at the moment

And here I have one setup for the Enemy1 Blueprint for calculating damage given to the player, whereas the other one was calculating for giving damage to the enemy:

Any and all help would be much appreciated!

I plan on making a collision overlap, for debugging purposes, and when the player overlaps it, it will calculate their strength against my character’s defense and so on. But, the issue I’m having is trying to get a reference to the Enemy Character so I don’t get yelled at by the editor. Essentially what I would put in the Object Wild Card in Cast to Enemy1.

Ohhh, okay gotcha. Yeah, essentially that’s what will happen. However, I have this as a Function that is saved inside of Enemy1. So, I’m assuming for the object wild card an overlap is what I would put there for the cast?

How are you “calling” the damage event? For example, is it when the enemy overlaps the player? When a projectile hits the player? etc

Yes, I understand the issue haha I was asking because usually the way you get that reference is from something like an “overlap” event or a “hit” event. Those events create a reference to a “hit/overlapped” actor which is what you would use to “cast to enemy”. That’s why I asked how exactly does your enemy “attack” the player?

Like this.

That “STOP” is a custom event/function or whatever you like you can call afterwards.

I just tested this and it still is throwing a fit. What specifically, node wise, would you want me to use? I tried Overlap BoxCollision, but that didn’t work and threw me an error. Not entirely sure what to use for the reference.

show me the setup and the error

Hmm… I got it to work, however I may need to play around with the numbers, because it is subtracting health as it should, but it may need some more testing. At least that cleared up one headache, haha. Hopefully.

Cool, glad it works now

The only question that remains is: where should I save this code to? Should it remain in Third Person Character, or should it be somewhere else, since this is calculating the damage that I receive and not the enemy. I can’t collapse it into a macro or function, so I’m not sure where the most optimal place for it be is.

I’d save the damage in the player character. Seems like a good spot, but it all depends on your setup. For this though it seems fine in plaster character