Sure thing. My weapons setup is a bit advanced, but I’ll snip only the important stuff.
Parent Weapon Class … Construction script → Add Camera Component, Attach to Gun mesh socket
After Camera addition we set a reference variable for it (Gun Camera). You’ll need it for ADS shooting.
Result:
My Weapons aren’t part of the character class. They are spawned in after pawn creation and attached to the pawn mesh.
Character Class Begin Play:: Spawn Weapons:
In the parent weapon class I have a “Char Ref” variable that is editable and exposed on spawn. This adds a reference to the owning pawn with out the need to cast.
Aiming Down Sight :
The IsADS? boolean is used in the animation graph state machine for transition to and from the ADS “State”.
Additionally I have a variable that references the players current camera. When I change perspectives FPP/3PP this variable is updated. It is “NEVER” set to reference the gun camera. Its purpose is to help determine which camera to use for shooting logic. If in 3PP I need to use the 3pp cam, otherwise fpp cam. If ADS always the gun cam.
All firing logic is in the parent weapon class. There I do a simple check [IsADS?] pulled from the weapons char reference. If true I use the gun cam, otherwise “Current Camera”…again pulled from the char reference.
e.g. projectile camera is a function local variable.
Cam toggle: