A chance rolled in _process() is rolled once per frame, so a faster screen rolls it more often. In our Godot 4.7 test randf() < 0.01 every frame made the fish bite after 3.32 seconds on average at 30 fps, 1.68 s at 60, 0.71 s at 144 and 0.42 s at 240. Roll the wait once when the line lands, then count it down with delta.
The code
Call cast() when the bobber lands in the water. Then call bite_due(delta) every frame and start your bite effect and the reel-in window on the frame it returns true. Call reel_in() if the player pulls the line out early.
extends Node
## Fishing bite wait that is the same at any frame rate.
## Call cast() when the bobber lands, then bite_due(delta) every frame:
## it returns true once, on the frame the fish bites.
@export var average_wait := 6.0 # seconds, on average
@export var min_wait := 1.5 # no fish bites sooner than this
var _left := -1.0
func cast() -> void:
# Roll the wait once, in seconds. It still feels like "could bite any moment",
# but the frame rate cannot change it.
var r := maxf(1.0 - randf(), 0.000001)
_left = min_wait - log(r) * maxf(average_wait - min_wait, 0.01)
func bite_due(delta: float) -> bool:
if _left < 0.0:
return false
_left -= delta
if _left > 0.0:
return false
_left = -1.0
return true
func reel_in() -> void:
_left = -1.0 # call when the player pulls the line out early
What we measured
We simulated 2,000 casts for each way at a steady 30, 60, 144 and 240 frames per second. Same random seed, two runs with the same numbers.
randf() < 0.01every frame: the average wait was 3.32 s at 30 fps, 1.68 s at 60, 0.71 s at 144 and 0.42 s at 240. Bites in under 1 second: 27.1%, 45.0%, 76.2% and 91.0% of casts.randf() < delta / 6.0every frame: 5.86 to 6.07 s at every frame rate. That fixes the speed, but 14.4 to 16.1% of casts still got a bite in under 1 second, some on the very first frame.- The script, set to 6 seconds on average and never before 1.5: 5.98 to 6.17 s at every frame rate, 0% under 1 second, fastest bite 1.50 to 1.53 s.
Why it happens
A 1% chance per frame is 1% every 1/30 of a second at 30 fps and 1% every 1/240 of a second at 240 fps: eight times as many rolls in the same time. Multiplying the chance by delta fixes the average, but a chance that can hit on any frame always lets some fish bite the moment the bobber lands. The script rolls the same kind of random wait once, as a number of seconds, starts it after the minimum, and counts it down by delta, so a slow frame or a fast screen only changes how finely it is counted.
What to change
average_wait: the average time to a bite, in seconds. Lower it for a better bait or a busier spot.min_wait: no bite comes sooner than this, so the bobber can settle and the player can look at it first.
The rings around the bobber: water ripple rings lying flat on the surface. Chances that fail too many times in a row: pseudo-random chance.
Ready-made fishing effects: Fishing VFX for Godot 4 has 25 presets in Stylized and Retro PSX looks, including nibble and bite effects, bobber ripples and splashes, fish shadows and a rare catch rainbow.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: Fishing VFX for Godot 4 has nibble and bite effects, bobber ripples and splashes, fish shadows and a rare catch rainbow, in Stylized and Retro PSX looks.
More how-tos for Fishing VFX for Godot 4: Ripple rings around a fishing bobber
More how-tos: Game systems
- Hover a 3D object inside a SubViewport
- A turned building that covers the cells it stands on
- An inventory that never loses an item and never overfills a stack
- A JSON save that loads back exactly what you saved
- Fire that spreads one cell per step, in every direction
- A pooled enemy that comes back as fresh as a new one
- An enemy that stops at the dead player and finds the respawned one
- Poison, burn and bleed that keep ticking when applied again
- XP, qi and gold that keep growing without going negative
- Count slot line wins with wilds in front
- Random directions spread evenly over a sphere or a cone
- Count a lap only when the car really went round
- Make a seed repeat: daily runs, replays and roguelike seeds
- Offline progress that counts the time the game was closed
- A chance roll without the long bad-luck streaks
- Check crafting recipes in any order, with the right counts
- Make HP and mana regen the same at any frame rate
- Damage over time with the right number of ticks
- Spawn enemies where the camera cannot see them
- Keep a chasing horde from stacking into one enemy
- Snap buildings to the right grid cell on both sides of the origin
- Make a cooking timer fire once, on time
- Pick from a weighted loot table with the right chances
- Level up as many times as the XP covers
- Walk a patrol guard to each point without overshooting
- Remove items from an Array while checking them, without skipping any
- Scatter spikes, roots or trees in a circle without overlaps
- Count and take crafting items from every stack
- Play random sounds and events without obvious repeats
- Pick the growth image so the ripe one shows exactly when the crop can be picked
- Turn a day counter into season, day and year without a day 0
- An enemy that dies once, however many hits land
- A fair shuffle you can replay
- A ghost that drives the lap at real speed
- A vision cone that does not flicker at the edge
- Move a group of units without a pile-up
- A sprinkler that waters a round patch
- A slot reel that always lands forward on the result
- A crowd of NPCs that never emote or bob in step
- A song position that moves on every frame
- Nodes your editor tool adds that stay in the scene