Getting Instantiated Projectile from Weapon for Custom Script

AlexM

New member
Hello! I'm writing my own script for processing damage done from weapons. The idea is that you can use different bullet types for each gun (fire, ice, normal, etc.), and the script will add the gun's base damage to the bullet. The damage values will be combined on the bullet itself, then received by different script on the hit character that reduces damage based on resistances to damage types.

To get my current solution to work, I need a script placed on the gun to get the projectile it just fired. I can't quite figure out how to do this, as the ShootableWeapon script seems to keep the SpawnedProjectile variable private. I also can't just use the prefab because the damage values need to be added onto the projectile's custom script at runtime.

Sorry if this is a bit convoluted. Basically my question is, how would I get the exact projectile spawned from the gun itself, as soon as it's fired? Any help would be much appreciated. Thank you!!
 
Have you had a look at the damage processor? This probably what you want to use.
 
Sorry for getting back so late, but thank you for your response! The damage processor isn't exactly what I need here, to be honest. I accidentally built my own before I knew you guys had one lol. Basically the only thing I need now is the projectile that's instantiated as soon as the weapon is fired. It would essentially be the same one from the "OnObjectImpact" event, but I need it before the impact. I can't seem to find a way to link the gun and the bullet it just fired. Does the ShootableWeapon script have a way to get a projectile the moment it becomes visible? I've tried using the "OnShootableWeaponShowProjectile" event, but it doesn't seem to work.

Edit: Ok, so I got the "OnShootableWeaponShowProjectile" event to work by changing the gun to show projectile on reload. This pretty much solves my issue, but it does call on aim as well. I don't think that's an issue, though.
 
Last edited:
Top