I’m relatively new to Unreal blueprints but I can code so bare with me.
I am creating a 2d top down space ship game. I am trying to use the AttachActorToComponent node to attach the ships turret configuration. I have made a few empty actors (no mesh or code) just arrows for where I want projectiles to spawn, the arrows in these various blueprints have the tag “Turret”. My idea was on firing/mouse click, to use GetComponentByTag to find “Turret” and spawn a projectile for each one. That way, no matter what weapon the player currently has, it will always work. I’m effectively trying to write it so the player can eventually get upgrades like double shot, triple show, diagonal arrow etc and it just switch the configuration by destroying the old config and attaching a new one. Maybe there’s a better way?
I need an array of all the possible weapon configurations/actor blueprints. That way I can search the array for getDisplayName == desiredWeapon and add the result to the actor variable currentWeapon. Then use currentWeapon, getComponentByTag “Turret” to spawn projectiles. I tried to make an actor array in the GameMode and it’s telling me I can’t edit it in class defaults.
Can anyone think of a way around my issue or a better way of doing it? I wanted this way as it could evetually lead to modular ships, if I can figure out how to switch in and out components on the fly.