Best Way of Doing Subclass with UCC

zented

Member
Hey,

I've made a subclass of MuzzleFlash.cs so I can make a custom muzzle script without touching the original script.
But in ShootableWeapon.cs, it will never find my subclass because of this line:

var muzzleFlashObj = m_SpawnedMuzzleFlash.GetCachedComponent<MuzzleFlash>();

So I started to subclass ShootableWeapon.cs to be able to change the line above without modifying the original ShootableWeapon script.
But I see there are a lot of private variables and functions, making it more complicated that I thought to subclass this one.

Maybe there is a simpler way to do this kind of thing.
If anyone can give some guidance :)
 
It depends on what you're trying to achieve really. You can assign your own custom muzzle flash prefab to each individual weapon under the "Muzzle Flash" section of its ShootableWeapon component:

1593599022883.png

And this prefab could contain any custom scripts you like.
 
Top