Hi. I’ve been following a course and have just watched a video including this piece of code that has call_deferred added as a separate line.
var explosion = explosion_scene.instantiate()
explosion.setup(pos)
call_deferred('_add_explosion', explosion)
func _add_explosion(explosion):
$Bullets.add_child(explosion)
All the previous times I’ve seen or used it it’s been appended such as on the end of calling a scene change. I was wondering if it’s normal to use it the way it’s been used in this code as the instructor is all over the place and doesn’t really explain much if anything.
Yeah I realise what it does. This just seemed like an odd way to use it compared to appending it. Why not $Bullets.add_child.call_deferred for instance.
It’s the same thing. Doing a deferred call via the method of the Callable class was possible only after the fist class functions (and Callable objects) were added to GDScript in 4.0. Prior to that there was only the Object::call_deferred() function. So you may be looking at some older code or the instructor is just used to doing it that way. Both ways are perfectly valid.
Thanks. As mentioned he hasn’t really been explaining anything. I can follow along ok but it’s hard to determine any particular reason for the way he does it compared to the previous lecturer in this particular sequence of courses. He briefly described what the code did as he was writing. This guy just writes and explains nothing apart from an overall outline at the start of each video about what’s going to be achieved. He also started with the tilemap collision set up and not explained. Thankfully that was explained in another course I’d seen.
Even if he explained things better I doubt he’d go into details about different ways you can make a deferred call if the tutorial is not specifically about deferred calls.
If this is a youtube video you can always try to ask him in comments or directly, about why he prefers this syntax.
Honestly even a brief sentence would be enough. This particular course also has tweens with no explanation from him but thankfully the pdf has a little more detail and says they animate a property between values. It’s not on YouTube that I’m aware of, it’s a Zenva course. Overall they seem alright but the instructors are a bit hit or miss depending on how you learn.
I.m.o, Zenva are not very good. I got some of their course bundles from humble bundle when i started learning how to use Godot. Often they sell like 25 courses for 20-30 dollars. They can be useful to just learn the basics and get used to working with different nodes etc, but most of the things that are actually done and taught are kind of off in one way or another. Some simple problems are solved in very convoluted ways when really there is already a simple method that is built into the engine, and other more complicated things are done in hacky ways that kind of works for the project in question but will be very difficult to expand upon or adjust for other projects. Still useful as a learning tool but keep in mind that a lot of the stuff is kind of sketchy.
Yeah that’s how I feel about the current course. For the most part I’m using them as a starting point for how various mechanics can be used. I got a years subscription and each course has a pdf with the full details so I’m going to work through all the Godot ones and maybe a few others before my subscription runs out. I’m mostly interested in apps, RPGs and crafting and so far the relative courses seem ok.