Why does weapon content need to be split into WeaponConfig and Weapon?

Just out of curiosity, why does there need to be 2 scripts related to weapon (Weapon and WeaponConfig)? The OnHit unity event can be added to WeaponConfig and can instantiate a prefab that has the sprite of the weapon? This way, only WeaponConfig is needed because Weapon only has OnHit function in it which invokes the onhit event.

You cannot have the UnityEvent on the ScriptableObject because you cannot assign hierarchy game objects to a scriptable object, so it would not be possible to assign the audio source to the hit event. Also, even if you could assign it, every weapon of the same type in the scene would then play the sound when OnHit() is invoked because there is only one instance of that specific WeaponConfig

1 Like

Additionally, we want our hit sounds to be coming from the location of the weapon, to give the best audio effects possible. Without that, all hits would come in at the same volume as if they were all happening right on your head.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms