Hello everyone! I'm having a small issue with my code. I want to start a timer ($ReelTimer
) when another timer stops. However, when the other timer stops and I call a true statement to run the function, it runs, but the timer does not start, and I do not know why.
Here is the code. (Some parts may have been removed so it's shorter):
extends KinematicBody2D
const moveSpeed = 150.0
var timesToTap = 10
var hasThrownLine = false
var caughtFish = false
var randomCatchTimer = rand_range(5, 30)
var randomFishGenerator = randi()%4+1
func _ready():
randomize()
func _input(event):
if Input.is_action_just_pressed("catch") && !hasThrownLine:
ThrowLine()
func _process(delta):
if caughtFish:
CaughtFish()
elif !caughtFish:
return null
func FishEncounterTimeout():
caughtFish = true
func PickRandomFish():
randomFishGenerator = randi()%3+1
print("From PickRandomFish(), it generated " + str(randomFishGenerator))
match randomFishGenerator:
1:
global.goldfishAmount += 1
2:
global.salmonAmount += 1
3:
global.garfishAmount += 1
func CaughtFish():
$FishEncounterTimer.stop()
$GUI/TappingText.show()
$PlayerSprite.set_animation("reeling")
$ReelTimer.set_wait_time(4)
$ReelTimer.start()
if Input.is_action_just_pressed("catch"):
timesToTap -= 1
print("Tapped the catch button upon catching fish. Taps left: " + str(timesToTap))
if timesToTap <= 0 && !$ReelTimer.is_stopped():
PickRandomFish()
timesToTap = 10
$GUI/TappingText.hide()
$Bait.hide()
caughtFish = false
hasThrownLine = false
if $ReelTimer.is_stopped():
print("Can no longer reel.")
timesToTap = 10
$GUI/TappingText.hide()
$Bait.hide()
caughtFish = false
hasThrownLine = false