You may want to used fixed processing, it has an exact time step.
Also you don’t want to use counters, because they will run at different speeds based on the frame rate. Use the delta time given by the loop. Accumulate it up to some timer value.
Why not just use a Timer? That’s what they’re for. Set its wait_time, autostart (or start it in code), and connect the timeout() signal:
func _on_Timer_timeout():
spawn_bird()
Thanks very much too,…i know, I can use Timer for that but I’m learning GDscript so I write scripts as much as I can.
Bishop | 2018-01-01 00:08
I understand that, but you shouldn’t write scripts just to write scripts. There will be plenty of scripting needed in your projects. Save the scripting for the things you need, and use the built-in engine tools - it’s the whole point of using an engine in the first place.
kidscancode | 2018-01-01 00:31
Thank you…you’re right…so, this is the meaning that AnimationPlayer or Timer nodes are faster than writing script - It is clear…but also faster for performance?..because built-in tools?
Bishop | 2018-01-01 18:24
Well, for something like a Timer, you probably wouldn’t see much performance difference, but in general, yes. The engine is written in C++ and many optimizations have been made before it comes to you. Scripting is intended to be the “glue” you use to tie the various components you need together, and to implement your game logic.
kidscancode | 2018-01-01 22:38
Thank you very much for your help and clarifications…i appreciate it.