Looks like you're not logged in

Login or Register to continue

Lesson Q&A

Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.

  • Optimization QuestionNokkemIn terms of optimization, would it be better to create a variable holding the reference to the node and therefore calling get_node() only once instead of calling it every time we press the spacebar in the process function or does it not make a difference? 10 10 Feb. 06, 2024
  • Different solution on how to boost the shipIceTeaGreedHi, I've found a more usefull or cleaner way of using the boost. Instead of creating a `var normal_speed`, we can also just use `max_speed += boost_speed` when pressing the boost key. And when the timer is done we simply use `max_speed -= boost_speed` We only need to adjust the boost_speed to 900.0 to reach a total of 1500.0 as used in the workbook but this way you have to keep track of fewer variables in the project. Also in the future if you want to change the boost speed or the max speed through ship upgrades it's easier this way. Just a different way of doing it, what do you guys think about this? full code: `extends Sprite2D` `var max_speed := 600.0` `var boost_speed := 900.0` `var velocity := Vector2(0, 0)` `func _process(delta: float) -> void:` ` var direction := Vector2(0, 0)` ` direction.x = Input.get_axis("move_left", "move_right")` ` direction.y = Input.get_axis("move_up", "move_down")` `` ` if Input.is_action_just_pressed("boost"):` ` max_speed += boost_speed` ` get_node("Timer").start()` `` ` if direction.length() > 1.0:` ` direction = direction.normalized()` `` ` velocity = direction * max_speed` ` position += velocity * delta` `` ` if direction.length() > 0.0:` ` rotation = velocity.angle()` `func _on_timer_timeout() -> void:` ` max_speed -= boost_speed` 7 7 Feb. 09, 2024
  • I opted for a different Slow down methodKenseiKCI tried using the Timer Node but I personally didn't like the controls that way since I wanted it to slowdown on releasing the button so I added a line to set the max_speed to normal_speed when releasing the boost button. Here's the code for anyone to try out: ```gdscript extends Sprite2D var max_speed = 600 var normal_speed = 600 var boost_speed = 1500 var velocity := Vector2(0,0) func _process(delta:float)-> void: var direction = Vector2(0, 0) direction.x = Input.get_axis("move_left","move_right") direction.y = Input.get_axis("move_up","move_down") if direction.length() > 1.0: direction = direction.normalized() if Input.is_action_just_pressed("boost"): max_speed = boost_speed if Input.is_action_just_released("boost"): max_speed = normal_speed velocity = direction * max_speed position += velocity * delta if direction.length()> 0.0: rotation = velocity.angle() ``` 1 5 Mar. 25, 2024
  • Blocking use of boost for a while after having used one?HollowHow would blocking the use of boost for a couple seconds after having used a boost be implemented? Would I have to add another timer node? 3 2 Feb. 13, 2024
  • Infinite boost changedMaziHello! I just did this because I wanted a not infinite boost. Without this modifying you can use it continuously. Is it a good idea or not good enough? Thank you for any response. ```gdscript extends Sprite2D var speed := 1200 var max_speed := speed var boost_speed := 3600 var boost_enabled = true var velocity := Vector2(0, 0) var steering_factor := 3 func _process(delta: float) -> void: var direction := Vector2(0, 0) direction.x = Input.get_axis("move_left", "move_right") direction.y = Input.get_axis("move_up", "move_down") if direction.length() > 1: direction.normalized() if Input.is_action_just_pressed("boost"): if boost_enabled == true: max_speed = boost_speed get_node("Timer").start() boost_enabled = false get_node("BoostTimer").start() var desired_velocity := direction * max_speed var steering := desired_velocity - velocity velocity += steering * steering_factor * delta position += velocity * delta if direction.length() > 0: rotation = velocity.angle() func _on_timer_timeout() -> void: max_speed = speed func _on_boost_timer_timeout() -> void: boost_enabled = true ``` 4 1 Aug. 16, 2024
  • Stuck in making boost input activateilliterate-spiderextends Sprite2D var max_speed := 600.0 var boost_speed := 1500.0 var velocity := Vector2(0,0) func _process(delta: float) -> void: var direction := Vector2(0,0) direction.x = Input.get_axis("move_left", "move_right") direction.y = Input.get_axis("move_up", "move_down") if direction.length() > 1.0: direction = direction.normalized() if Input.is_action_just_pressed("boost"): max_speed = boost_speed velocity = direction * max_speed position += velocity * delta rotation = velocity.angle() if direction.length() > 0.0: rotation = velocity.angle() I followed the steps and understood them well. The input key for boost is on space as it showed in the pictures. Did I do something wrong in the code? 3 1 Feb. 11, 2024
  • We create var timer: Timer = get_node("Timer")BrutalHeroWe create a variable that can't be found in the final script. Is this variable needed? Why is it not showing in the final script shown at the end of the lesson : ship.gd ```gdscript var timer: Timer = get_node("Timer") ``` 5 1 Feb. 03, 2024
  • Naming breaks lessonTKarlssonIf you name your Timer to anything but Timer it breaks the validation. Just rename it to Timer and you can move on to the next and remember to avoid "improving" or experimenting with the code/naming on your own. 8 0 Dec. 01, 2024
  • When you store a reference to a node in a variable, what kind of variable is that reference?SophiaIs there a variable type called... reference, or something? Anyway up until now everything has seemed normal and understandable but these objects felt like some kinda dark sorcery to me. So thank you for including the glossary link so I could read up and understand it and not feel too mystified. 4 0 Nov. 19, 2024
  • max_speed a bit confusing in the instructions palieuxThe below instruction is a bit confusing. The func *on_*timer_timeout() is shown at line 4. ```gdscript # Place this at the top of the script, next to the boost_speed variable. var normal_speed := 600.0 func _on_timer_timeout() -> void: max_speed = normal_speed ``` we should have ```gdscript var max_speed := normal_speed ``` in that place. The code is right in the Code Reference though and the *on_timer_timeout() is a the end of the code.* It was a bit confusing first, but we figured it out with my son :) Great course so far btw. My son is having fun and really enjoys it. 1 0 Nov. 09, 2024
  • Should I be using the workbook project for non-practice stuff?NasscarIve been using the workbook project for my non-practice related stuff and I'm confused if I'm supposed to be using that project for the lesson since I have to disable the practice plugin whenever I'm done and have to set the sprite back to the ship sprite from the bullet sprite and delete the extra child nodes on the Sprite2D. 2 0 Oct. 31, 2024
  • Crashing on boost/timer startfront-railMine is crashing when I press the spacebar to initiate boost. The program will freeze up and it will spit me back to Godot. It also won't quit the "run" window until I run it again and then close it (without pressing the boost button). I tried changing the input mapping to make it a different button, but it made no difference. It even behaves the same when I copy and paste the solution code. The error message is at line 18 / get_node("timer").start() "attempt to call function 'start' in base 'null instant' on a null instance." 2 0 Oct. 28, 2024
  • Tried out writing my own code firstOsprixxI tried my hand at my own code after seeing the animation and before reading the page and I actually managed to get it to work! I made a child timer of the Ship called BoostTime set to One Shot for 2s and wrote this code: ```gdscript velocity = direction*max_speed if Input.is_action_just_pressed("boost"): $BoostTime.start() if $BoostTime.is_stopped() == false: velocity *= 2 ``` It seems to work perfectly! I'm super impressed with the course so far as I would never have been able to work this out myself without it! Now to actually follow the lesson 1 0 Oct. 11, 2024
  • Can't access the Timer's functions for some reason?IcyKaliI'm pretty sure my code is identical to what it's supposed to be, and I see in history it says the signal timeout() has connected to the Sprite2D node, but Godot is throwing an error saying, "Standalone lambdas cannot be accessed. Try assigning it to a variable" and doesn't even let me play the scene. This is the part that's throwing the error: func _on_timer_timeout() -> void: EDIT: I noticed that the green door with the arrow that appears when there is a connection isn't visible next to this line... but I'm sure I connected the signal to Sprite2D like I was supposed to so I can't figure out why it's not working. The connection icon next to the Timer node is visible. When I just remove this part the scene will play and work as it should (though the ship won't slow down after boosting of course) so I'm pretty sure I wrote everything correctly. 7 0 Oct. 10, 2024
  • Little changes to variablestedious-horseI was a bit confused with the var max_speed, as it suggested it IS already the max speed even with booster. I opted for another version including a third variable that is set as the current_speed and called in the ready func at the beginning. ```gdscript extends Sprite2D var normal_speed:float = 600 var boost_speed:float = 1500 var current_speed:float var velocity: Vector2= Vector2.ZERO func _ready() -> void: current_speed = normal_speed func _process(delta: float) -> void: var direction = Vector2.ZERO direction.x = Input.get_axis("move_left", "move_right") direction.y = Input.get_axis("move_up", "move_down") if direction.length() > 1.0: direction = direction.normalized() if Input.is_action_just_pressed("boost"): current_speed = boost_speed get_node("Timer").start() velocity = direction * current_speed position += velocity * delta if direction.length() > 0.0: rotation = velocity.angle() func _on_timer_timeout() -> void: current_speed = normal_speed ``` 1 0 Oct. 05, 2024
  • Please Help. enchanted-dugongI commonly get this error when trying to do anything in Godot. *Attempt to call function 'start' in base 'null instance' on a null instance.* func _process(delta: float) -> void: if Input.is_action_just_pressed("boost"): max_speed = boost_speed get_node("Timer").start() I have the timer as a child of my sprite2d. Nothing I do works. Every time I ever try to make a project I have this issue. 1 0 Sep. 06, 2024
  • ConstantsCocaFor a simple code like this where some of the variables store values that don't change, and there will be no feature like speed upgrade, is it better to use a constant? e.g. ```gdscript const NORMAL_SPEED : float = 600.0 ... max_speed = NORMAL_SPEED ``` 2 0 Aug. 23, 2024
  • Which script to editauthorized-scorpionI'm getting a bit lost on which script I'm supposed to be editing at what time. I'm completing practices as I go and the open scripts are adding up and the four, I have open now, are bullet.gd, character_diagonals.gd, charcter_input.gd, and ship.gd. Which one to use for "The boosting ship" lesson? Have I missed an instruction? 2 0 Aug. 15, 2024
  • L4 P1 only works if Timer node is called "Timer"raincloudI was confused for a bit with this practice. The practice said I was failing all but the first objective, but the circle appeared to be moving as expected. I realized that because I had renamed my Timer node to "BoostTimer", it wasn't being identified by the practice. As soon as I renamed it back to "Timer" and updated my get_node() call, I passed. 1 0 Aug. 12, 2024
  • Suggestion:dofudengamesMaybe , if the ship moves fast that would be the fire? 4 0 Aug. 04, 2024
  • I don't understand the Timer in var timer: Timer = get_node("Timer")faint-reindeerI get that we have a variable and that we want that variable to represent the get_node("Timer") call. What I don't understand is the Timer = before calling the function. Why is it necessary, what does it do? Wouldn't var timer = get_node("Timer") be valid? 1 0 Jul. 19, 2024
  • The advice about not copying/pasting feels strangeCaleb WarnerI just cannot follow the advice in the practice section here, and I think I understand where it's coming from but it isn't working for me. (The courses are working fine overall, this is just about that one piece of advice!) We're asked to practice these methods by typing them out ourselves, but I can't possibly remember them without looking. One thing I find indispensable about these lessons is the parts where you explain *why* the code is doing what it's doing; as someone who tried to learn these things on my own in the past I often found myself rereading my code and not understanding it - and these lessons have been a big help in fixing that problem. Still, while your lessons take me to the point where I can understand the vital information of why, say, normalizing works how it works, or why one might store a timer or other nodes in a variable for access later, these lessons do not (and I would argue should not be expected to) get me to a place where I can from memory reproduce the code in full. I understand that this could (partially) be a question of goals as a learner, and I want to stress again that I really am getting a lot out of these lessons, but it feels to me like there's a big difference between a practice helping me to use the code I just learned, particularly practices asking me to do something slightly different from what we just learned (which I imagine will come later) - and a practice expecting me implicitly to just remember, immediately, the names of all-new function calls and the proper syntax therein. I hope my tone is coming through because I am happy to be taking these lessons. I just don't know if there's some trick I'm missing that makes it a reasonable expectation for us to remember the new syntax and function calls that fast, when the best I can do is learn *why* it works and *how* I would use it - and I feel really grateful for that level of understanding. 2 0 Jul. 10, 2024
  • Nothing changes if you uncheck the box "one shot"Nikita MyshkinI don't understand a bit how the property works "one shot". When I uncheck the box, nothing changes. Why? 1 0 Jun. 21, 2024
  • get_node("Timer") doesn't autocomplete?DeadIndGamesThis is one hiccup with Godot that gets to me. Typing the long form of get_node doesn't allow the engine to actually find the node and update the autocomplete so when you press . to access the properties you just have to know yourself what function or property you are looking for. Storing the timer as a variable fixes this issue and this could be a big tripping up point to someone new to writing code if they don't see the autocomplete they might assume they messed something up. 1 0 Jun. 19, 2024
  • Debugging errorploped00Hi all! I've tried to use the debugger (just to experiment) adding a breakpoint wherever in the code and the game window is closing due to the next error: > W 0:00:00:0175 MaterialStorage: Project setting "rendering/limits/global_shader_variables/buffer_size" exceeds maximum uniform buffer size of: 16384 Does anybody have an idea about how to solve it? 9 0 Jun. 14, 2024
  • Why use a timer node and not just a variable?JohnyWuijtsNLBefore doing the lesson, I tried to add the boost myself. Instead of the timer node, I created a timer variable that stores a float, then decrease this by delta every frame to make it go down by 1 each second. Then I check if it's below 0 or not to handle the boost logic, and set it to a positive value when I press the boost button. What's the benefit of adding a whole new node just to have a timer? 4 0 Jun. 08, 2024
  • L4.P1 Should test if the Timer is set to "one shot"slim-lemurAs it is, I had forgotten to set it to one shot, and still passed. As forgetting to specify one shots can lead to unexpected outcomes, it might be a good idea to reinforce this behavior with a check. 1 0 May. 25, 2024
  • Controlling the boosteuphoric-sheepHere's what I wanted: - The player can boost when the boost key is held - When the boost key is released, the player no longer boosts - The player's boost is limited by a timer - The timer does not rundown when the player is not boosting I achieved it pretty well I think! Here's my code: ```gdscript extends Sprite2D @export var maxSpeed := 600.0 @export var boostSpeed := 1200.0 var speed : float var velocity := Vector2(0,0) var boostLeft := true func _ready() -> void: speed = maxSpeed func _process(delta: float) -> void: var direction := Vector2(0,0) direction.x = Input.get_axis("move_left","move_right") direction.y = Input.get_axis("move_up", "move_down") if direction.length() > 1.0: direction = direction.normalized() velocity = direction * speed position += velocity * delta if direction.length() > 0.0: rotation = velocity.angle() var timer = get_node("Timer") if boostLeft == true: if Input.is_action_just_pressed("boost"): speed = boostSpeed timer.start() if Input.is_action_just_released("boost"): speed = maxSpeed timer.stop() else: speed = maxSpeed if Input.is_action_pressed("boost"): print("No Boost Left") func _on_timer_timeout() -> void: boostLeft = false ``` My next challenge: having the boost recharge over time! 1 0 May. 13, 2024
  • Func _on_timer_timeout() In the script before connecting timer to nodeperiodic-skunkIn the practice L4.P1 the function for the time out is already in the script. It's very easy to forget to connect the timer to the sprite node. Is it possible to change this for future students? 1 0 Apr. 29, 2024
  • When i press space the ship space game close him selfBibizeextends Sprite2D var max_speed := 600.0 var boost_speed := 1500.0 var velocity := Vector2(0, 0) func _process(delta: float) -> void: var direction := Vector2(0,0) direction.x = Input.get_axis("move_left","move_right") direction.y = Input.get_axis("move_up","move_down") if direction.length() > 1.0: direction = direction.normalized() if Input.is_action_just_pressed("Boost"): max_speed = boost_speed get_node("timer").start() velocity = direction * max_speed position += velocity * delta if direction.length() > 0.0: rotation =velocity.angle() Did i miss something ? 5 0 Apr. 26, 2024
  • Trying to connect a signal to ship.gd goes into boosting_circle.gd instead?LarueNot sure if this is just me, but when I try to connect the Timer's timeout() node to my ship.gd, instead it opens up the next practice lesson's .gd file and adds it there instead. What's stranger is that even when I turn off the GDQuest plugin, it still does this. When I am in the "Connect a Signal to a Method" window, Ship is what is highlighted each time I try. Since it won't let me connect the signal, I keep getting an error about the Node not being found anytime I press the spacebar to boost in practice. Should I try to start over? 2 0 Apr. 23, 2024
  • Switching to max_speed := normal_speed wasn't describedkooky-seahorseIn the previous lesson max_speed was set to a float (600.0). At the end of this lesson it has ben set to := normal_speed. I get that his makes sense with the new normal_speed variable but the code still works with max_speed := 600.0 so might be good to have a quick explanation about the change :) 1 0 Mar. 19, 2024
  • boost doesn't work in vertical-down-right direction.datiswousWhen I do boost, it does not work when pressing down and right together. Other directions work fine. Any idea? 4 0 Mar. 18, 2024
  • Why not use Input.is_action_pressed instead?datiswousI found **is_action_pressed** but don't understand the diffgerence and why **is_action_just_pressed** is chosen here. 1 0 Mar. 08, 2024
  • Boost sometimes workingTucanBigMy boost works aswell as time timer stopping it, but it does not work everytime I click "space" , sometimes I have to click it twice or 3 times for it to activate. But when I am in boost and I continuously click space it will work everytime until I stop pressing space. My spacebar is fine because normal typing recognizes the space input. 6 0 Mar. 03, 2024
  • About pressing "boost" key fastgorohaThank you Nathan, I'm very enjoy with the course so far! Now I'm curious about is there the case that user press and release "boost" key very fast in a short time when **_process()** function is not running? My understanding so far is **_process()** is a function that called in a loop (by Godot engine), so maybe there is a gap time between the calls, like: |<-- _process() frame N -->| <-- user press & release "boost" key -->|<-- _process() frame N + 1 -->| .... I can't reproduce that issue, so I'm not sure my understanding is correct or not, and wonder there is the case in reality game development? Assume it happened, do we miss a key pressed event? 2 0 Mar. 02, 2024
  • boosting the ship in the workbook exerciseBehnderHi!, I just want to say, when you try to do the "make the circle boost" exercise, you have to do it doing something in the "boost" input. But previous in the lesson you suggest you can call it whatever you want(which is true), so i called it "BOOST", but then I had trouble figuring out why my code failed. The solutions came to me very fast(changing or creating a new input called "boost"), but I think for new people, maybe in this case, you have to encourage to use this specific name. Sorry for my English, i'm still learning. thanks! 1 0 Feb. 22, 2024
  • L4 P1 only works if input is named "boost"MisterateI had used "Boost" as my input name during the lesson, however when I set up the boost for the example problem, it would not work. I took a guess that maybe it was looking for a lowercase "boost" and that fixed it immediately! 3 0 Feb. 14, 2024
  • Comment wordingMark_KarnowskiThe comment in the practice: "# Replace the pass keyword with the code to change the speed to *max_speed*..." should probably be changed to: "# Replace the pass keyword with the code to change the speed to *boost_speed*..." or "# Replace the pass keyword with the code to change the max_speed.." 3 0 Feb. 07, 2024
  • Small typo in Hint 1 of the PracticeTJThere is a typo in Hint 1 that made it confusing to understand. I suppose the word 'on' is missing, like so: > Then, you can call the start() function **ON** the result like this: ... 1 0 Feb. 06, 2024
  • Glossary text for "signals" is cut off at right marginTJI'm really enjoying the course so far! Just a small issue I would like to report: Today when I clicked on the glossary term for signals, the text was cut off at the right margin of my browser window. I'm using the Chrome browser. There also doesn't seem to be a horizontal scrollbar to allow me to read the rest of the cut-off sentences. If I could post a screenshot then I could demonstrate it more clearly, but I hope the issue is clearly described. Thanks guys, I love the course! 1 0 Feb. 06, 2024
Site is in BETA!found a bug?