Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Nexxt |
I’m still learning, but i seriously need help on this one, is there a way to force a player to drop one loot after timer stops?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Nexxt |
I’m still learning, but i seriously need help on this one, is there a way to force a player to drop one loot after timer stops?
Reply From: | timothybrentwood |
var loot_timer
func _ready():
loot_timer = Timer.new()
loot_timer.wait_time = 5
loot_timer.one_shot = true
# here is where you can specify what function gets called
# when the timer timers out, in this case it's drop_one_loot
loot_timer.connect("timeout",self,"drop_one_loot")
self.add_child(loot_timer)
func some_func_to_start_timer():
do_some_stuff()
do_other_stuff()
loot_timer.start()
# called when loot_timer times out based on the connect() function above
func drop_one_loot():
var loot_to_drop = get_loot_to_drop()
drop_loot(loot_to_drop)
That code would go in your player class. Your implementation of get_loot_to_drop()
and drop_loot()
are entirely up to how you’ve structured your loot system and game as a whole though. I would need more information about how your code is structured if you need help with that part.
Now that I think of it, is this for one loot to be dropped? Or the entire loot? Cuz I forgot to specify that the player can choose what to drop (1item) from the player’s inventory
Nexxt | 2021-05-03 16:48