Hi all!
Question, I have a player with a weapon. With the G button he can open the store and buy upgrades for it. After exiting the magazine, the weapon must load new data about its rate of fire from the Autoload script. How can I best do this? I thought about adding a variable override to _process, but I’m afraid this is not the best solution because it seems to me that this may affect performance (I’m not an expert in game engine development).
Don’t hit me if the question seems stupid
so once you buy it, it should update its properties? You can use signals for that. If you need clearer instructions i need to know how your code looks like for upgrade buying and updating the weapon properties
main scene:
cabine have mashine gun:
mashine gun have script:
shop panel:
and buffs MG(mashine gun)
the purchase goes like this:
sorry for the large amount of information, I don’t know how to write it differently
in your autoload you can emit the signal that the data has been updated:
signal mg_updated
func setMGdata(damage, ...):
... # Here all upgrades happen
mg_updated.emit() # emit the signal after all updates have been made
And now you can connect the signal to your player with the gun:
# MachineGun-Script
func _ready():
Autoload.mg_updated.connect(_on_mg_updated)
func _on_mg_updated():
# apply the updates here
2 Likes
Thank you!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.