Godot Version
v4.2.2
Question
I am wanting to create a system where a small number will add to a value when an item is picked up.
For example, our ninja character can pick up items dropped by enemies. One of those items is a shuriken boost that doubles the rate of fire for 5 seconds on a cool down timer. Instead, I would like for when our ninja hero picks up the item, it adds a small rate of fire, and that small rate continues to grow as the shuriken items are picked up. The same would go for the speed boost item as well.
Here is the current code. It works fine, but the fire rate and speed boost will only fire within the time of the timers:
Constans to set the values on the Player
const START_SPEED : int = 200
const BOOST_SPEED : int = 400
const NORM_SHOT : float = 0.5
const FAST_SHOT : float = 0.1
and then the functions to kick them off
func boost():
#$boostTimer.start()
speed = BOOST_SPEED
$puSound.play()
func quick_fire():
#$fastFireTimer.start()
$shotTimer.wait_time = FAST_SHOT
func _on_shot_timer_timeout() -> void:
can_shoot = true
func _on_boost_timer_timeout() -> void:
speed = START_SPEED
func _on_fast_fire_timer_timeout() -> void:
$shotTimer.wait_time = NORM_SHOT
Finally, the on_entered_body from the items:
func _on_body_entered(body):
#noodle
if item_type == 0:
$bonusSound.play()
body.boost()
#heart
elif item_type == 1:
main.lives += 1
life_label.text = ("X ") + str(main.lives)
#star
elif item_type == 2:
body.quick_fire()
#delete item
queue_free()
I am fairly new to Godot and expanding on a tutorial, so any help is appreciated!