can someone help me with this cast

hello can someone please help me with this casting
I created multiple actors each one represent a weapon, and I added to each actor different mesh and because weapons have different sizes , the length of the blade where I want to trace the Collision during attack is different.

after picking up the weapon it is stored in an array and the player can’t change the weapon pressing c key then an instant of the weapon will be placed in the socket in the right hand.

during the attack animation I want to trace the Collision depending on the weapon that I’m using, therefore I need to cast to the weapon to get the start and end tracing arrows from the weapon actor.

I understand that when casting I need to specify which instant I am casting to, how can I tell the blueprint that I want the instant that is stored in the right hand socket.

note : I tried creating an object in the third character blueprint that store the same actor that is in the right hand socket and I tried pluging it as an object for the casting but it did not work.

additional questions
is this way in general good or is there another more efficient way?
is it possible to create a collision box inside the weapon actor and use it for tracing during the attack?

In your example here, you need to cast the ‘child actor’, first pull an pin from there and search for ‘get child actor’, then cast.

In fact, if you make a blueprint which only holds a mesh, and the two arrows, then you can make all the weapon blueprints children of that.

That way, you only need to deal with WeaponParent, and you always have access to the mesh and arrows. No fiddling with different weapon types :slight_smile:

thank you so much for helping me with the casting problem
sorry I deleted my previous reply, but I found a better approach in general

right now I have no issue casting and I came up with a very efficient solution.
since I already have two yellow arrows in my main characters blueprint that I used previously for tracing without problem, all I need to do right now is just changing their position to match the red arrows in the weapon actor blueprint however the problem is that even after assigning the word transformation the yellow and red arrows are not in the same location
the yellow arrow is changing location but it does not match the location of the red arrow

I solved the issue by using get relative transformation instead of get World transformation also I needed to change the hierarchy on the left to assure that the arrows are children of the same socket where the weapon will be equipped

I probably wouldn’t be able to solve it without your help with the casting

Well done :slight_smile:

It’s a bit of a pain, using child actors. One way to simplify things, is to use blueprint inheritance. See here, I make the parent, no mesh set yet, and two arrows

Then, for the ‘axe’, I inherit

and edit that

Now, I can still set the class, so I get the right kind of weapon, but after that I can always talk to it in the same way ( I don’t need to cast for each type of weapon )

Another way, is to talk to the child actor with an interface ( The weapons are still in a hierarchy, this is just an easier way to talk to the weapon )