But when hit RMB for the toggle it crashes. I’ve tried relative location, I’ve tried making the move occur in the weapon class instead. No matter what I do it seems as though trying to move the actor crashes…
What exactly is “Weapon”? Are you 100% sure it will always be valid? Do you ever assign the spawned “Wp” to your weapon variable?
Try adding a check such as
Ah, just read your answer more carefully. This is what is happening.
The TSubClassOf in the projectile example is used to specify the class of the spawned projectile, it is not used to store a reference to your weapon. In your case you need create a variable in your header such as:
ATestWeapon* MyWeapon;
Then, after spawning your weapon you assign it to your weapon variable:
MyWeapon = Wp;
Finally, when you move your weapon you simply do the following: