How to Cast an Actor?

How can I cast an actor?

Actor class
image

I am struggling to with this casting method. What reference should satisfy the cast?

Created an actor class and spawn it on the actor hand.
could anyone can explain me in detail about the cast?

Hey there @Inevitable_King! First you’ll need to get a reference to it if you need to cast to it. Where are you casting from? Player character? If so you’d get the reference from maybe line tracing in the case of an FPS or Collision in the case of a Third person character for example.

If you spawned it and attached it to the player you can get the reference from your spawner:

Though this way you don’t even have to cast and can just save the variable instead.

Hey, thank you for your time and reply, so I am doing this cast in AnimBP. So, the scenario is, I have an actor class that called BaseWeapon_c++ (it derived from c++ BaseWeapon actor class ) now, I need a reference of BaseWeapon_c++ so i can get the location and rotation and assign to relative with hand. When you press left right mouse button the gun should align with head bone so, it looks like ADSing.

I figure it out. Thank you sir.
image

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.