Cant set rate of fire for each weapon

Godot Version

v4.4.1.stable.official [49a5bc7b6]

Question

For creating different weapons, I’m using a custom class that extends Marker2D where I defined my rate of fire (and other things too) and the shooting mechanic. Then I’m creating nodes with this class as child of my player node. The problem is that they keep using the default values (if I set them) even if i tell it in _ready() function. As far as i know only thing that i should do is to change the values in the inspector. But it doesnt work for me for some reason. Also here are screens of my code.

Does anybody know where is the issue? I have no idea where to look anymore.

Your derived class needs to recalculate CoolDownTime in _ready.

e: like this:

func _ready()->void:
    RateOfFire = 3000
    CoolDownTime = 60.0 / RateOfFire

Simply overriding RateOfFire only overrides that variable; other variables that use RateOfFire are not automatically updated as well.

(On a side note, please don’t post screenshots of code but post as preformatted text by enclosing your code with three backticks (i.e. ```.))

1 Like

Thanks! Now it works. I need to think more how to write the code more nice. Still learning it.
P.S. Got it. Write code like this