Blueprint Communication with Custom Events

Hi there,
Whenever I try to cast from one character blueprint to an actor blueprint to fire off a custom event, I run into a problem. I don’t have an “Object” to cast to. I don’t completely understand how the casting works. What am I supposed to put into the object section?

Thanks.

Hi TalkingIsGreat,

What a cast does is check a specific object or actor reference to see if it is of a specific type. What are you attempting to do specifically? Have you tried reading through our blueprint communication documentation, there is a wealth of information available that may help to explain the concept of casting, event dispatchers, and interfaces there:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/CastNodes/

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/EventDispatcher/

For a basic explanation of casting →

Think of it as if you (an actor) are asking a specific object or actor what it is. You have approached the object and said “Are you this?” Now, without a reference, you are still asking “Are you this?”, but you have nothing that you are specifically speaking to. In this case, you will need to find a way to pass a reference of the actor you want to ask, either through a trace, object to object interaction, overlaps, etc. Once you have that reference, you can perform the cast, then use the "as " pin to get specific variables and functions from within the casted object.

OK, so casting only works with a reference to the actual instance of the object or class. Technically you can plug anything into there as its a wildcard, but it will only cast if its of the same class your casting too. If its not the correct class, the cast will fail.

In this case you’ll want to add an instance of your GenerateEvenGraph to your game level, and then add a new variable based off that class in your BPCharacter class. You’ll then need to somehow get the actual instance of the GenerateEventGraph class and plug it into that variable. This is quite tricky though and a lot of work, so we often do it a different way.

Instead of casting to GenerateEventGraph from inside your player blueprint, cast to your player from inside GenerateEventGraph and add to the LPoints variable. You can do this by casting to BPCharacter and for the object input, plugin the “Get Player Character” function. then as BPCharacter, just drag off to get the lpoints variable and do whatever you want with it. It is sometimes much easier to do this rather then the other way around.