Problem with inherited class

Hi, I am creating a simple game with a few weapons. So, I have 2 main classes (derivated from MonoBehaviour) :

WeaponManager, which siwtches weapons and detect input.

Weapon, that can be derivated like below:

-WeaponProjectile (launches projectile)

-WeaponParticles (for spray-type weapons)

using UnityEngine;

public class WeaponParticles : Weapon
{
    public ParticleSystem m_particles;
    public float m_rateMax;

    private ParticleSystem.EmissionModule emission;

    private void Start()
    {
        base.Init();
        emission = m_particles.emission;
    }

    public override void FiringStart()
    {
        Debug.Log("FiringStart()");
        emission.rateOverTime = m_rateMax;
    }

    public override void FiringStop()
    {
        Debug.Log("FiringStop()");
        emission.rateOverTime = 0f;
    }
}

This is WeaponParticles class. I call FiringStart() and FiringStop() from parent class Weapon via an override. I can see the debug logs in the console, so the methods are properly called. But the emission rate of the particles doesn’t change. I tried with other things like changing a light intensity but it doesn’t work either. I tried to derivate this class from MonoBehaviour for testing, including the input detection and calling the methods directly and it works. I am really lost here, and couldn’t find answers…

@Amphet, show us the code that worked. in this derived class, where are you getting a reference to the Particle system? Just stating private ParticleSystem.EmissionModule emission; doesn’t create the ParticleSystem, and you must get a reference to the component somewhere…

I believe that If you want each type of weapon to have a unique particle system, you need to have a reference to unique Particle System component for each - you need to assign the reference in the derived class.

Simple variable types and structs like floats or vector3s are different because if those are defined on the base class, you get a copy of them when you create an instance of the derived class.

But in the case of reference variables - those that point to objects such as GameObjects and Components - you don’t get a per-instance copy, you get a reference to the same object. If you want a to reference to a unique object, you need to assign it in the derived instance.