I’d like to spawn a projectile from my BP_Rifle and i would need some variables such as muzzle location, velocity, etc from my MainFireArmBP.
Main reason i want to spaw the projectile on my BP_Rifle is because i would like to have different values for each of my guns. So i was thinking having like an interface, which i add to each of my guns and, that way i can have seperate values for each of those varaibles. Am i on the right track?
I tried experimenting with an interface message function but it didnt really work out the way i wanted to. How should i approach this? Also, worth nothing the BP_Rifle is a child of MainFireArmBP.
Make MainFireArmBP parent (just like you did). In it make variables that describy parameters of weapon, like mode of firing (single shot, auto, full auto, and maybe continuous like flamethrower ie start/stop), make another that tells type of projectile that should spawn.
Those variables should be game tags (they are like abetter enums).
Child weapon BPs should be cosmetic only (and define muzzle offset, type of firing, type of projectile).
You can also define all weapons in Data assets: define meshes, type of fire, type of projectile. Then child BP just reads correct data assets, and sets everything in MainFireArmBP.
Interface would be needed if MainFireArmBP was casting to child weapon BP, but that is not needed. If child BP is casting to parent it will always be to MainFireArmBP. Also you want to make child BPs with almost no code (so you do not need to copy/paste that code to every weapon, which makes using inheritance pointless, at least for weapons, because you can use some parameter variables in parent).