Casting node help

First of all Thanks for taking the time to look at this. Second of all congrats if you read all of it :slight_smile:

i have recently started playing around with UE4, I’m 42 years old and the only other programming/game creation i have done was on a ZX Spectrum.

For the most part I think I am picking it up quite quickly, or rather its sinking in quite well. But I don’t seem to be able to grasp the concept of the casting node properly. I think I have the general idea of it, please correct me if I’m wrong.

I need to cast to another blueprint if I need to retrieve variables or run an event.

I have a cast set up in my (animation_BP) to go to (Playercharacter_BP) with object set as {Get player Character} and I think that works because the information I need is in the ****CharacterMovement ****in Components of the Blueprint.

But If my (PlayerCharacter_BP) is holding a sword (Greatsword_BP) and I want my (Animation_BP) to communicate with my Greatsword_BP to turn on a particle effect, using notifications at the start of the montage animations, I don’t understand what goes in the Object pin. My own presumption would be something to do with the mesh because I’m spawning the particle along bone sockets, but have failed miserably every time I try.

Does the required object pin depend of the information I require from the blueprint or does it depend on the type of blueprint class created? Like Actor/Pawn/Character/PlayerControler

please could someone explain the mechanics behind the casting object, in a way that a non programmer could understand or point me in the direction I could learn from, everything I have read so far is full of jargon. I would rather learn the concept than somebody just saying you need to connect the object pin to this.

Thanks in advance for anyone that takes time out of their day to read or reply.

In anim BP you’ll cast to character class. As PlayerCharacter_BP -> Get the sword and cast to Greatsword_BP. From there you have 100% access to all of the swords functionality, events, variables etc.

Casting gives you that 100% access to the class. Without casting you only get top level access.

thank you both for the reply, it gives me a lot more reading to do and another way of trying to try understand it… at the moment it feels like its a bottleneck in my learning.

i have been reading most of the day about casting and im not sure if im using it in the right way, so i will try to explain a bit clearer. In my animation i have a notifier called TrailStart.

](filedata/fetch?id=1845407&d=1608566031)
https://forums.unrealengine.com/core/image/gif;base64

when that triggers im trying to cast to my BasicGS blueprint like this.

to perform this event.

first of all, is this the correct way to do this? or would something like blueprint interface be a better way to do it?
sorry to drag up the post again but i feel like im missing something, or rather i keep overlooking something.

my brain is fried with so many different people using different analogies.

yeah, the left pin is blank because whatever i plugged in, got error message saying it would always fail.

but i think you’re right, i need to do something else and come back with a clear head.
thanks for the response.

When you spawn an actor in your character class (great sword) that’s going to be attached you should promote the “return value” to variable. Name it “Great Sword Ref”. Beyond this manual reference approach there’s no other efficient way to really get a reference to it than “get attached actors”… which returns an array that would need to be looped through.

https://i.imgur.com/QknjxCu.jpg

At Spawn there’s no need to CAST.

https://i.imgur.com/BBDpOGy.jpg

In your anim BP you should initialize a reference to the character. The **“Blueprint Initialize Animation” **event is executed once when the Animation Blueprint instance is created to perform initialization operations.

https://i.imgur.com/nsKfS0q.jpg

From this point forward you have 100% access to the characters data AND you no longer have to cast to the character from the anim BP.

From here it’s as simple as … Get reference to character -> get reference to sword -> call event.

https://i.imgur.com/omuiif7.jpg

https://i.imgur.com/SzFubRf.jpg

https://i.imgur.com/NWsfKMI.jpg