PaperCharacter cast to actor issue

Hello. I have been trying to create an event for a PaperCharacter, in which there is a collision box that triggers some code on the character on begin overlap, that is then sent as a cast to, to a different PaperCharacter in the scene which calls an event that destroys the target actor. My problem here is that no matter what i try, i can’t get the cast to, to not fail. I have tried using a variable to set the PaperCharacter reference as target for the cast to, and setting an array variable for an interface to be called as an event instead of the custom event on the target actor, but none of them work. I then tried to create a 3PP template and create a similar scenario with the normal Character, which seems to work fine. Here the cast to does not fail. Anyone have any insight as to what might be happening, and what could be done to fix it?

Regards.

You’re suffering from the same problem as many many people who use UE youtube tutorials. You think that casting is for communicating…

When one actor overlaps the other, you get a reference from the overlap event. You can just destroy the other actor then. If you want to be sure you’ve got the right KIND of actor, then you can cast it to the paper character, just to check.

Because casting is for checking the type of an actor, not for communicating between actors.

Can someone please put this in the site header of youtube Unreal Engine tutorials… :melting_face:

2 Likes

Can you show the code?

It sounds like you are trying to check to make sure that the object colliding with your actor is one that can “deal damage”. If so, then there are two ways you can go about this.

Let’s say you have a projectile actor that is the source of damage, and a target.

Option 1: You have an overlap event triggered in the sources blueprint, which then calls an interface function. You implement the interface function in your target.

Option 2: You add a gameplay tag, or implement an interface in your source. You add an overlap event in your target, and check if the actor that overlapped has the desired gameplay tag, or implements the desired interface.

I would recommend using interfaces over casting in almost every situation. But gameplay tags also require fewer steps.

You could also use the “Class is Child Of” node.

Thx for the responses, they were very helpful.

I have resolved the issue. I removed the enemy character reference variable from the object wildcard, and put in the other actors from the begin overlap event instead.

1 Like

This is the blueprint i am using for this event. The first one is the player and the second is the enemy. (this is the working version. the version where it didn’t work; i had a reference to the enemy in the object wildcard instead of other actors)

1 Like