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.

  • Steering vector visualisationarhinostormJust wanted to say that the visualisation scene with the vector arrows is fantastic. It's really helped me wrap my head around what the vector maths is doing. Love it. 7 13 Feb. 20, 2024
  • Second delta necessary?joyous-finchA friend of mine told me that the delta at line 26 in the complete code is redundant, as the velocity is already adjusted as speed over time in the previous line. Is this correct? I am on the fence, I am really trying to wrap my head around the function of delta in steering and moving simultaneously, it reminds me of working with derivatives at school, which i was terrible at! 26 11 Feb. 03, 2024
  • lerp()tuktuk22i just comeback and redo this lesson, and found out there is other way to do the steering using lerp(). ```gdscript velocity = lerp(velocity, desired_velocity, STEERING_FACTOR * delta) ``` is there any particular pros/cons of doing either way or is all about choices? 1 3 Jul. 24, 2024
  • Things have gotten too complex, too quickly!leafI feel like things have suddenly gotten too complex and with an incredible jump from just one chapter to the next. At this very moment, I don't feel confident that I could reproduce some of the results from the previous chapters, and while reading through this chapter I am drawing a blank and things just aren't clicking. Perhaps I am lacking in basic knowledge in math required to move forward? Not sure what to do next, any insight would be greatly appreciated and welcomed! 2 3 Apr. 17, 2024
  • var steering := desired_velocity - velocityMaxWas resulting in an error for me. "Cannot infer the type of "steering" variable because the value doesn't have a set type." I was able to get rid of the error by removing the colon. I have an idea as to why this is happening, but I am uncertain. 3 3 Feb. 06, 2024
  • Here's my codebogus-craneIt works I just want to show my work that's all extends Sprite2D #these are the vars that are used in multiple functions var steering_factor := 10.0 var normal_speed := 600.0 var boost_speed := 1500.0 var max_speed := normal_speed var velocity := Vector2(0, 0) func _process(delta: float) -> void: var direction := Vector2(0, 0) #these lines take the inputs 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() #these lines set the direction if direction.length() > 1.0: direction = direction.normalized() #these lines set the steering stuff var desired_velocity := max_speed * direction var steering_vector := desired_velocity - velocity #this line sets the velocity velocity += steering_vector * steering_factor * delta #this line moves the player position += velocity * delta #these lines makes the player face the direction it's moving if direction != Vector2(0, 0): rotation = velocity.angle() func _on_timer_timeout() -> void: max_speed = normal_speed 1 2 Jun. 27, 2024
  • My memory is horridKalmaroIs it bad that I'm not so good at remembering commands? I can remember concepts well enough, but if you tell me to type it out, I draw a blank. 4 2 Jun. 03, 2024
  • Limiting Turning-Speed / Implementing Turning-Radius?HollowI thought the ship was too jerky when doing large angle-changes so I tried implementing a turning radius by making an if statement that if the angle difference between the velocity vector of this frame and the last frame exceeds a value (I used 0.1 for testing) a scaled-down steering vector would be subtracted from the velocity again. I put this if statement below the velocity calculation and above the position calculation and created a variable "var velocity_last_frame = velocity" before the velocity calculation. But all this didn't seem to do much, so my question is if my approach even makes sense and if not how a turning-radius could otherwise be implemented? 6 2 Feb. 14, 2024
  • The use of DeltaMr-EdThe math for understanding why we have to use delta in these types of calculation is much to complex for my brain to grasp. I've seen full videos about it, with detailed math and after 5 minutes I just can't follow it anymore. But what I do understand is physics. What we are trying to determine is the acceleration of the object (in this case the ship). The calculation for acceleration in physics is speed/time^2. The difference between this and computer programming is that we don't really have a way to tell computers what the **** time is. So, in order to make it a constant (akin to real life time) we determine the time it takes the computer to finish a calculation. With this we determine that it takes 1 second for the computer to make 60 calculations (hence the 60 fps). Since the speed of the calculations is determined by several factors (like computer speed, ram speed, or the background processes, etc.) it may happen that the 60 calculations per second may be more or less. Some computers may make 30 calculations per second instead, for example. In order to compensate for this, some calculations (not all) need to be multiplied by "delta" which is a calculation of the time it took the computer to process frame 1 and then frame 2. Therefore, if each frame is constant, an object will move at the same speed all the times, but if the framerate is jittery, the delta will make sure the object moves more (or less) to compensate for the time it didn't move. 1 1 Nov. 13, 2024
  • Fuzzy vs concrete understanding of game mathshigh-level-eelMaths has never been my strong suit. In fact, I'm just plain terrible at it! I'm new to game programming and programming in general and a lot of the physics and algebra introduced in this session is pretty alien to me (I'm still trying to get my head around how a vector is more than just a set of coordinates, but also a direction and a length, let alone smooth steering mechanics). In the long run, how much am I going to suffer by having a rough understanding of the math side of things vs being Will Hunting or Alan Turing when creating games? 1 1 Jul. 08, 2024
  • Is steering a type of interpolation?WalruswareI can see the resemblence of a starting position, a goal position, and an amount to move towards the goal. So I'm just curious if this counts as a lerp or something similar? I understand not wanting to bog people down with jargo so this is not a complaint at all about the language used in the lesson. I just noticed the similarities and wanted to check if I was right. 4 1 May. 13, 2024
  • Do you have any topics on making debug nodes like the one in steering visualization?iadgybf8iawgFor example, topics about visualizing path, movement, vector changes, collision, state changes and grids etc. In 2d and 3d. Also, how do you make custom tools to configure variables at runtime? Can you make it only works under development build? And remove them in release build? 3 1 Mar. 13, 2024
  • += reminderantsmathJust a small suggestion that even I'm not 100% convinced on. But I stared at this part trying to figure out how it got the ship to move correctly (which it was): velocity += steering * steering_factor * delta And I will admit, most my misunderstanding (about 15 minutes) was forgetting we had the "+=" and not just "=" in the equation. It might be useful for people who might be putting their math hats on trying to follow everything and overlooked the "+" in "+=". 1 1 Mar. 01, 2024
  • My brain BSOD's trying to figure out the mathMartinBI've been trying to make sense of the steering and steering_factor math that gives the ship that smooth turn. But it's just not clicking. 2 1 Feb. 21, 2024
  • Just a KudosRomanRiot**I love having the sections for "Your code should look like this..."** Having a checkpoint to ensure you're up to the most current coding iteration is immensely helpful in avoiding simple, yet time-sucking mistakes. Thanks! 1 1 Feb. 11, 2024
  • Mathematical equivalent to (desired_velocity-velocity)lowenWhat is steering velocity based on, acceleration? 16 1 Feb. 08, 2024
  • Why steering instead of steering_vector?theSchroeI was going through the text and after I read this "It's what we call the *steering vector*." I was expecting that the respective variable in the code would also be called "steering_vector" (as you also did with steering_factor). In my opinion the code would be more consistent with the text of the chapter. 2 1 Feb. 06, 2024
  • Different steering during boostjumbo-lionJust wanted to share how I combined L4 and L5 to make it harder to steer while using boost. extends Sprite2D ```gdscript #Speed var BoostSpeed := 1500.0 var NormalSpeed := 600.0 var maxSpeed := NormalSpeed var velocity := Vector2.ZERO #Steering var SteeringFactorNormal := 10.0 var SteeringFactorBoost := 2.0 var steeringFactor := 10.0 #Player State var is_boosting := false # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: #Handle inputs var direction := Vector2.ZERO direction.x = Input.get_axis("move_left", "move_right") direction.y = Input.get_axis("move_up", "move_down") #Normalize diagonal vectors if direction.length() > 1.0: direction = direction.normalized() #BOOST! if Input.is_action_just_pressed("boost"): maxSpeed = BoostSpeed is_boosting = true get_node("Timer").start() #Make boost turning stiff if is_boosting: steeringFactor = SteeringFactorBoost else: steeringFactor = SteeringFactorNormal #Smooth turns var desired_velocity := maxSpeed * direction var steering_vector := desired_velocity - velocity #Move the ship velocity += steering_vector * steeringFactor * delta position += velocity * delta if direction.length() > 0.0: rotation = velocity.angle() func _on_timer_timeout() -> void: maxSpeed = NormalSpeed is_boosting = false #Setting steering back to normal ``` 1 0 Dec. 20, 2024
  • question about velocitymilk_manrevisiting this lesson and playing around with the code led me to the following question about this code segment: ```gdscript var desired_velocity: V = * max_speed var steering_velocity: V = desired_velocity - velocity - velocity += steering_velocity * steering_factor * delta + velocity = steering_velocity * steering_factor * delta print(velocity) position += * delta ``` I wanted to see what happens with the movement if we just assign the values to velocity. The ship will move far slower and the moment you stop moving the ship, it will turn around back and forth like crazy for a millisecond and I don't understand why just assigning the value to velocity instead of increasing leads to this behaviour. Also velocity value barely changes after a couple of process calls, like this: ```gdscript (40, 0) (38, 0) (38.1, 0) (38.09501, 0) (38.09525, 0) (38.09524, 0) ``` and then the value (38.09524, 0) just repeats. Shouldn't there be more of a difference in the value of velocity? btw my steering_factor is 3.0 1 0 Oct. 17, 2024
  • I want to print(steering_vector) if it's higher than desired_velocityPurpleSunriseHello, I think I understood the concept behind the fact that if the steering factor is higher than 100.0 the steering_vector will be higher than the desired_velocity. So I thought I'd do this(The commented lines are just a test I was doing to avoid to reset the timer every time I boosted the ship in order avoid infinite boosting spamming the space-bar): ```gdscript extends Sprite2D # var timer_on : bool = false var normal_speed := 600.0 var max_speed := normal_speed var velocity := Vector2(0,0) var steering_factor := 100.0 var boost_speed := 1500.0 func _process(delta: float) -> void: var direction := Vector2(0,0) direction = Input.get_vector("move_left","move_right","move_up","move_down") if direction.length() > 1.0: direction = direction.normalized() if Input.is_action_just_pressed("boost") : # and timer_on == false: # timer_on = true max_speed = boost_speed get_node("Timer").start() var desired_velocity = max_speed * direction var steering_vector = desired_velocity - velocity velocity += steering_vector * steering_factor * delta position += velocity * delta if direction.length() > 0.0: rotation = velocity.angle() if velocity.length() > 600.0: print(velocity) ``` I don't want to waste too much time struggling over this. I just wanted to know if there was a way to double check when the steering_vector is higher than desired_velocity other than just checking visually? If I just print the velocity, I can see that when I change direction either x or y is higher than 600 so I get it it's higher. I was just trying to find a way to print it ONLY when it's higher. but I don't know if this is the right thing to do. I just wanted to see clearly that the steering factor is higher than the velocity. Also I wanted to have more clear how to calculate the steering vector with actual numbers? **let's say I am going up and I press "right"** steering_vector = *desired_velocity*(600.0,0.0) (*because I just pressed right*) - *velocity(*0.0,-600.0*) (our current velocity because we are going up)* **So the steering vector would be 600.0,-600.0?** then we add to our velocity (current velocity right?) the steering vector * 100.0 * delta(0.016)? velocity += Vector2(600.0,-600.0) *100.0 * 0.016 (*So we are adding a vector2 (960,-960)?*) So in this case this equation is 0.0,600.0 + 960.0,-960.0? Sorry if this is really confusing, maybe I don't have the concept 100% clear in my head. 3 0 Oct. 10, 2024
  • Good lessonaeishabadThis lesson was very informative on vectors and it strengthened my understanding of them significantly. I feel if I did this course with no prior knowledge of physics or any other type of math that involves vectors, I would have had a lot of trouble. To those having trouble, I recommend trying to go step by step and understanding the fundamentals and purpose of each variable. After doing so, itll start to make sense why velocity is changed in the way it is! Keep coding for real guys! 1 0 Oct. 04, 2024
  • About steering_vectorHazlarHi, `velocity += steering_vector * steering_factor * delta :` A- if steering vector = **- - - - - - - - >** ( its length, here to the right ) = 8 dashes We multiply 8 * 10 = 80 * delta = 1.33. so velocity , the first displacement represents 1.33 dashes which will be deducted to 8 after. B- If I multiply this 1.33 dash by delta again = 0.022 . In A I represent the max displacement at the first frame of 1.33 and it should stop there, why still do it in B? C- Context of understanding: The process function is called if I am at 60 fps, 60 times per second. So when I read the code inside it is the description of what happens on a call, therefore an image. The displacement variables if they are not multiplied by delta, become absolute values ​​on a frame so if `max_speed = 600` would move the ship 600 pixels per frame, 60 times but equivalent to 1 second so 36k pixels/second. I understand that Velocity is a variable that is neutral at the base, it is worth 0, and without multiplication by delta, up to point A, where it is encapsulated by a calculation that is defined by frame since delta is used there. So I can't understand the nuance between A and B. 5 0 Oct. 02, 2024
  • I don't think I'm even editing the right script.scientific-tarsierThe L4 and L5 activities in Godot talk about a circle but use the bullet image, the L5 information in the website talks about steering a ship, and when I test my changes the 'bullet' doesn't even move. I tried deleting everything but the direction input to see if that worked but it just broke the test, and when it showed me the test file I couldn't find a place where it referenced what file it was testing from. I'm currently deleting the whole thing and extracting a new version to see if me saving something in the wrong place or refreshing something wrong might have caused this. 1 0 Oct. 01, 2024
  • L3P5 - Can't get this one to passfrozen-wormI used the following code on this practice: ```gdscript extends Sprite2D var max_speed := 600.0 var velocity := Vector2(0, 0) var steering_factor := 10.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() # Add code to calculate the desired velocity, the steering, # and add to the current velocity before changing the position. var desired_velocity = velocity * max_speed var steering_vector = desired_velocity - velocity velocity += steering_vector * steering_factor * delta position += velocity * delta if direction.length() > 0.0: rotation = velocity.angle() ``` I notice that the sprite on the left doesn't move, while the sprite on the right does. 1 0 Sep. 12, 2024
  • I got confusedCocaI got confused by the images with the vectors last night, maybe because I was sleepy, it would be less confusing if the vectors were named on the image, and the subtraction was displayed beside the resulting yellow vector. I felt like the wrong order subtraction was a intermediate step to get the final result, because it goes from that example to "Finally, we add a fraction....". 1 0 Aug. 23, 2024
  • Velocity += ... Why the addition not the equal sign?MaziHello! I just dont understand in the function _process the "velocity" why changed to this: += from the simple velocity "=“. Could you please tell me why? Maybe I just too lame to find the answer in the lesson but I can't find it. Thank you! ps.: I saw the "+= reminder" post what is Great! but there is no answer for me just the fact, we have to use the "+". 4 0 Aug. 20, 2024
  • Doing normal even I changed steering_factor over 100 ?CyberI don't know if this is normal, but my steering is working completely fine with steering_factor over 100, nothing strange happend. But as the course said it should be a problem right ? Is it normal ? 1 0 Aug. 06, 2024
  • Experimenting with the ship's script - Adding acceleration to the ship?leafI'm trying to figure out how to add an acceleration variable to the ship, and essentially make the speed build over time (slowly at first, then build much faster - making it more realistic I think). I've tried quite a few things already; I think I would need to use a lerp and a minf? Any clues or hints on doing something like this? I'm also attempting to make the ship rotate and only able to accelerate forwards; instead of being able to turn quickly backwards like we do here. I was able to do this, but in order to do so the movement system we learned here quickly caused a lot of problems. Would I likely need to redo everything here, or is there a way to use some of what we learned in a system like this? *Forgive me if I don't know the words to explain this, but I do know what I want in my mind.* 3 0 Aug. 05, 2024
  • How does the desired_velocity work again?untimely-dogfishThe calculation of desired_velocity is max_speed * direction. So we multiply 600.0 with the direction vector. From my understanding, new vector, namely desired_velocity would still point in the same direction as velocity, and not the new direction. Of course that can´t be, because the game works as wished. 1 0 Aug. 03, 2024
  • How can I return the angle of the ship to spawn a bullet in the same direction as the ship is facing?leafHey guys, I'm not sure if this is the appropriate place to ask this question; it's somewhat related to the lesson, but kind of off topic. I am wanting to use the direction variables of the ship we used here, to instantiate a bullet from the global position of the ship and be pointing in the exact same direction with the exact rotation/angle, from where the ship was facing during instantiation, and from there the bullet would move in that direction and no longer change with the ships variables thereafter. I was able to instantiate onto a marker placed in front of the ship, but I want to know how I can use a vector2 from the ships position instead. With the marker alone, I and struggling to make it work as well. I'm having a hard time trying to find help for it in the exact way that I am trying to do it. The bullet I am using is NOT circular, and is more like an oval, so having trouble with ensuring the right angle as well as it's important for the visual effect. Even just being pointed in the right direction, or some kind of hint would work wonders here! 13 0 Jul. 27, 2024
  • What if the ship is going at a constant speedwell-groomed-seahorseJust a curious question and getting way ahead of myself but so if we want to ship to go on a constant speed before any input would we have to put a if statement that if no input the position is a constant speed variable by a x movment Vector2(400,0) then if there is an input do the code we learned? 4 0 Jun. 20, 2024
  • Question about understanding the algorithmHazlarHello This is the calculation of a potential other direction in order to moderate its turn so that it is less instantaneous but slightly oblique. And even if it goes straight its speed goes from (0.0) to "desired_velocity" little by little. In other cases we frame the value of "steering_factor" between 0.0 and 1.0. Why? Because it is a portion of the distance that connects two desired points: the desired one and the current one, so a diagonal has a length of 1.0 on a pixel, so choosing 1.0 as "steering_factor" means taking the whole portion (if we consider the smallest displacement per change of direction). (Because it is represented by the yellow arrow) Am I right? Thanks for your patience 3 0 Jun. 16, 2024
  • Some precisions may be needed to improve vector maths understandingOptimisticDogI totally understand that the vector maths here can be hard to understand for many people, including myself. I have to drew many graphics to understand what is going on when calculating the steering vector. What I was wondering about what to precise is: - A good contrast between a location and a movement, a vector <3,2> and a point (3,2) are not the same things. - An explicit sentence to explain that the difference between the desired velocity and the current velocity (steering vector) is relative to the current velocity, not the origin nor the sprite location (I figured this by "monkey-calculating") - In this lesson, all is about movement and not locations. Bonus: If someone has a brilliant.org account, there is a great interactive course for vector math using a game as example. The content is not free but as GDQuest, you pay for gold content. I used this course and it helped a lot. 2 0 Jun. 05, 2024
  • I don't understand the steering vector formula logicConradThe steering_vector formula states "steering_vector := desired_velocity - velocity" and I have no issue with the desired_velocity variable as we defined it in the line before it, but according to our code the only reference to the variable velocity by that point is at the very top which states "var velocity := Vector2(0, 0)". Doesn't this mean that all we are doing is subtracting Vector2(0, 0)?? How does the code know that the velocity is the "current velocity" when all it should know is that it is a Vector 2 with (0, 0) coordinates? 8 0 Jun. 04, 2024
  • Optional Challenge Helphaunting-camelAfter having a mini-breakdown during Module 6 have come back to the start to see if things can stick a little better (and having a go at the optional challenges that come up this time around to see if I've actually learnt anything). Unfortunately I can't work out what's gone wrong. My method was to compare what the velocity calculation was to what it became. ```gdscript velocity = direction * max_speed ``` ```gdscript var steering_factor := 10.0 #.... var desired_velocity := max_speed * direction #Thought process being we've replaced the velocity with a variable of desire var steering_vector := desired_velocity - velocity velocity += sterring_vector * steering_factor * delta ``` So theoretically ```gdscript if direction.length() > 0.0: rotation = velocity.angle() ``` Should become something like this ```gdscript var turning_factor = 10.0 #... if direction.length() > 0.0: var desired_rotation = velocity.angle() # "replacing" rotation with a variable var rotation_vector = desired_rotation - rotation rotation += turning_factor * desired_rotation * delta ``` But this causes a freespin when turning left, up or down, and holds the last angle when moving right. I thought it might have been an overshoot problem as mentioned in this lesson, but swapping the subtraction on line 5 changed nothing. I've at least made some progress whilst writing this post, as to begin with it wasn't even rotating - I just need to find the right balance between "no rotation" and "all the rotation"! Ideally not looking for the actual answer but if there's a nudge available for either something I might have missed, or a syntax might be off it'd be greatly appreciated. ETA: I've noticed that I've written the rotation incorrectly, following previous example should be ```gdscript rotation += turning_factor * rotation_vector * delta ``` which at least 'solves' the problem of no rotation when turning right. Now we're in freespin in all directions. Progress? :P 2 0 May. 31, 2024
  • What is purpose of "delta" when calculating "velocity"?PixelbladeWhat is the full purpose of the "delta" factor in the line of code below? Is it to reduce the size of the "steering_factor" or does it also adjust for changing framerates? ```gdscript velocity += steering_vector * steering_factor * delta ``` 1 0 May. 30, 2024
  • Ship turning instantly (or almost) in opposite directionsp_dev_When turning, for example, from left to right, the direction changes immediately, just as in the previous lessons. In diagonals (v. g. from top-right to bottom-left), the ship turns around very quickly. Is it supposed to be this way? How could one tackle that? 7 0 May. 29, 2024
  • Trouble with codeTjI have been able to work the code through the lessons, but I am working on my own and it seems I am having trouble with my own coding I am working on for my project but I am having trouble with connecting player input script to the canvas layer of my main code structure. Already ran this through AI says you can connect with "string" but Godot says it needs to be int func _ready(): start_match() # Connect signal from the PlayerInput node var player_input = get_parent().get_node("PlayerInput") player_input.connect("draw_triggered", self, "_on_draw_triggered") 9 0 May. 27, 2024
  • Recommend adjusting wording in "Practice Makes Perfect" regarding steering vectorslim-lemurSo in the "Practice Makes" Perfect" instructions, there's this part: 1. Calculate a steering vector. It's the difference between the ship's current and desired velocity. But mathematically speaking, it should be worded as, "...the difference between the ship's desired and current velocity". Now, it's unlikely that someone would be confused by this, as these practices directly follow the lesson that even mentions why (desired_velocity - velocity != velocity - desired_velocity). But it might be worth changing. 1 0 May. 25, 2024
  • Colored arrows explained for clarityvilithosLet me try explaining this to see if I got this right as I feel like am losing brain cells trying to visualize this without colored arrows: - The red arrow is the `desired_velocity` made of `max_speed * direction` which is where the player points through inputs - The blue arrow is the `velocity * delta` used to move the ship by the pixels that have been calculated - The yellow arrow is the `steering_vector` made of `desired_velocity - velocity` to have a *vector in place* at the "end" of the velocity arrow, to point at the endpoint of the players input (`var direction`) This is done to move the ship towards a direction by pixels calculated every frame * delta time. 1 0 May. 21, 2024
  • Read the Whole Lesson (it might contain the info you crave)TwifflerThis course is so thorough! I wish I had this resource when I first started using Godot. Anyways, I went ahead trying to figure out how to understand the vector math and visualize it on paper while to my surprise at the end of this lesson there was a nicely put together visualization in the solutions project! It is like you guys thought of everything. 1 0 May. 11, 2024
  • Am I supposed to remember this?Mr. RodentThis is my third time doing this lesson throughout the various iterations of this course inside two years. The first time I quit this course after the blue noise lesson, because all of this got way too complicated too quickly. So I decided that the course not really for beginners as advertised, and went to do Harvard's CS50 instead. I've finished CS50 now, have been studying programming in a school setting for over a year now and still this damn lesson goes over my head. Now all the other coding parts are easy though so far, I just really suck at these mathy parts. Is it hopeless for me? Can I get by with copy pasting these things in the future or should I just give up on Godot? Why is this stuff taught in the very beginning of the course anyway? 4 0 May. 11, 2024
  • godot 4.2 when going from left to rightHkeyHello, i was trying out the course m4 l3,4 and 5 but i noticed that in the videos on the course-s page when you go from left to right the ship remains on the same Y axis, but when i try to do that in my project it changes axes slightly. i thought it was a mistake i made in my code but by copy and pasting the endpage one the problem persists, why is it? is there any way to fix it? 3 0 May. 06, 2024
  • Having trouble visualizing what the lines of code doesWacksfordHello! i have been fiddling around with godot for a couple of weeks but recently got your courses after watching some of your youtube videos. i am having trouble really understanding what these lines of code are doing, i get to the point where i can read the code and understand that desired velocity is just basically the max speed in given direction, but if becomes blurry in my head when calculating the yellow arrow (steering vector if i understand it so far), ive tried drawing it out on pen and paper to get a grip on it but i am either missing something or doing something wrong. do you have any visual help to show exactly what is happening while showing the concept like live values? i was able to get through the practice easily because i did remember all the lines, but i do as ive said have issues with understanding the concept of it 11 0 May. 04, 2024
  • Sprite blurry when movingTheKmankHey, been having an issue where the sprite is slightly blurry when moving and leaving a "ghost" of itself very slightly behind it as it moves. Not sure what is causing it. 6 0 Apr. 24, 2024
  • Initial code blocks in "Coding smoother momement" section confusingMelabelaThe first two code blocks are confusing if read at face value, and could be improved with some variable-naming and/or comments enhancements. In the first block, i.e.: ```gdscript func _process(delta: float) -> void: # ... + var desired_velocity := max_speed * direction velocity = direction * max_speed # ... ``` - Both (new) `desired_velocity`, and (existing) `velocity` compute to the same thing, since their right-hand side is effectively the same. - Possible improvements could be: ```gdscript + # new movement from current input + var desired_velocity := max_speed * direction + # old movement from previous frame - velocity = direction * max_speed + velocity = last_direction * max_speed ``` Then in the second block, i.e.: ```gdscript func _process(delta: float) -> void: # ... var desired_velocity := max_speed * direction + var steering_vector := desired_velocity - velocity velocity = direction * max_speed # ... ``` - *(looks like syntax error)* `velocity` is used in `steering_vector` (line 4), before it is *assigned* (line 5)... - Ignoring previous point, think this has same problem as in first block. Shouldn't `steering_vector = (0, 0)`, as `(desired_velocity == velocity)` ? - To clarify both, should include a global `var velocity = ...` declaration above `func _process()` line, to make `velocity` stateful 2 0 Apr. 23, 2024
  • What about different framerates?Sigil60fps was used as a reference for all our calculations and explanations for what the ideal `steering_factor` should be. However, depending on the device, the fps can be all over the place. It's not like we can adjust the steering_factor based on the delta (or maybe that is the solution), so how would we deal with this? I know this is kind of outside the scope of the lesson, but I was just curious. 1 0 Apr. 22, 2024
  • Receiving an error when allowing the computer to decide the assignment type for "desired_velocity/steering_vector" variables.leafWhen I use := with the **desired_velocity** variable, I receive an error. Line 29: "Cannot infer the type of "desired_velocity" variable because the value doesn't have a set type." Clearing the colon clears this error, but I see that it is being used in the given code example. And I really want to understand why it's returning an error. I have checked the code, and compared it to the examples. Also, I have tried using := for one or the other of these variables as well, if I do both variables with this assign structure (:=), only the top variable returns the error (**desired_velocity**), and if I use = for the top variable while using := for the bottom variable (**steering_vector**), it alone returns the error for the that lower variable. What am I missing here? (I have a feeling it's very silly) *Thank you for your time in advance!* Here is what I am using, without error: ```gdscript extends Sprite2D var boost_speed := 1500.0 var normal_speed := 600.0 var max_speed := normal_speed var velocity := Vector2(0, 0) var steering_factor := 10.0 func _process(delta: float) -> void: # set direction variable var direction = Vector2(0, 0) # get player input direction.x = Input.get_axis("move_left", "move_right") direction.y = Input.get_axis("move_up", "move_down") # normalize vector for input direction if direction.length() > 1.0: direction = direction.normalized() # boost mechanic / reset timer if Input.is_action_just_pressed("boost"): max_speed = boost_speed get_node("Timer").start() # finding and setting desired velocity for ship movement var desired_velocity = max_speed * direction var steering_vector = desired_velocity - velocity # speed and moving the ship calculation velocity += steering_vector * steering_factor * delta position += velocity * delta # set direction of ship to match p.input if direction.length() > 0.0: rotation = velocity.angle() ``` 3 0 Apr. 17, 2024
  • Types of steeringAbdul Hannan AhmedHi! I am really stuck on this steering chapter. There are many types of steering. Can you tell which type of steering is this, so that I can get some help on the internet? Thanks in advance! Regards 1 0 Apr. 13, 2024
  • The exercises are buggy if restartedBlinkGriffonFor whatever reason, I can't pass L2P1 The bullet lesson again. Every subsequent lesson, L3P1, L3P2, L4P1 and L5P1 have shown the Bullet scene while calculating whether I 'passed' the keypoints or not. I have stopped and restarted the M4 a few times because I couldn't do the whole module in one sitting, which seems where the problem started. 7 0 Mar. 29, 2024
  • ship_with_steering_visualization errorMuseDoes Hi, I had a weird error happen when I launched the steering visualizer. I tried to move the ship, but nothing happened. After poking around a little, I figured out that this was because there was nothing in the Input Map. So I added the move_left, move_right, move_up, and move_down and their keys to the Input Map. The visualizer worked great after that. I'm not sure what caused the Input Map to be empty in the first place, or if anyone else had that issue pop up too, but I am pretty happy with myself for being able to troubleshoot it. 2 0 Mar. 11, 2024
  • Visualize the steering vectors (M4.L5)NorbertI've reached the title "Visualize the steering vectors" in the course and am trying to start the scene "ship_with_steering_visualization.tscn" with F6. The spaceship doesn't move when I press "WASD" and I get thousands of errors. What can I do? 3 0 Mar. 01, 2024
  • Importance of when variables are declaredacrobatic-crocodileIn the process function I would have thought that there would be no reason you couldn't declare: **var** **desired_velocity := max_speed * direction** and **var steering := desired_velocity - velocity** at the start of the function. It seems like these variables shouldn't do anything until later in the function when velocity is changed to **+=** **steering** * **steering_factor * delta**. However I found that defining those variables at the start of the function resulted in the ship not moving, I had to move them down to beneath the **if direction...** statement like in your example code before the ship would move. Why is this? 2 0 Feb. 24, 2024
  • How does the engine avoid Zeno's Paradox?intent-mantisI wanted to ask about lines 23 to 25. To me, it seems like if we only change **velocity** by a fraction of (**desired_velocity** - **velocity**), the ship will never actually reach **desired_velocity**. Is there a point where the values become close enough that the engine will round them together? 1 0 Feb. 19, 2024
  • Clarification SuggestionRomanRiotIn the **"Avoiding overshooting the desired velocity" section**, below the bullets, you may wish to add a word to the sentence to increase clarity. > "...our velocity will overshoot the `desired_velocity` vector, making **[the ship]** jitter erratically." Thanks! 1 0 Feb. 11, 2024
  • Tried making my own visualizationsstunning-wolfI checked out ship_with_steering_visualization.tscn but it was too ott (4 nodes, 3+ scripts, loads of functions) so I tried making my own with Line2Ds. This would really help my understanding in another project, but if I can't get the lines to draw properly then I'm clearly missing something. Here's the relevant code (Code block option is messing with my whole comment, so had to leave default): extends Sprite2D @export var max_speed := 600 @export var boost_speed := 1200 @export var steer_factor := 10 @onready var boost_cooldown := $"../BoostCooldown" @onready var debug_lines := { "velocity": $"../Debug/Velocity", "steering": $"../Debug/Steering", "desired": $"../Debug/Desired", } var velocity := Vector2.ZERO var default_speed : int func _ready() -> void: default_speed = max_speed func _process(delta: float) -> void: handle_input() var direction = handle_direction() var velocity_desired = direction * max_speed var steer_vectors = velocity_desired - velocity velocity += steer_vectors * steer_factor * delta position += velocity * delta if direction.length() > 0: rotation = velocity.angle() debug_draw_vectors(velocity_desired, steer_vectors, velocity) func handle_direction() -> Vector2: 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: direction = direction.normalized() return direction func handle_input() -> void: #Boost if Input.is_action_just_pressed("boost"): if boost_cooldown.is_stopped(): max_speed = boost_speed boost_cooldown.start() func reset(value: String) -> void: match value: "speed": max_speed = default_speed func debug_draw_vectors(velocity, steering, desired) -> void: debug_lines["velocity"].set_point_position(0, position) debug_lines["velocity"].set_point_position(1, velocity) debug_lines["steering"].set_point_position(0, velocity) debug_lines["steering"].set_point_position(1, steering) debug_lines["desired"].set_point_position(0, position) debug_lines["desired"].set_point_position(1, desired) func _on_boost_cooldown_timeout() -> void: reset("speed") Tasukete onegai. 2 0 Feb. 11, 2024
  • L1P5 doesn't workRudiI tried to hand code L1P5, but couldn't get it to work. So I copied the final version from the Solutions Project. But it still doesn't pass the test 5 0 Feb. 05, 2024
  • The ship.gd changed over courseRudiInitially, you start with inputs "up" "down" "left" "right" and then later on the ship.gd has the traditional standard "move_left" "move_right" etc etc. I don't recall having to apply those changes to the ship, but to the projectile yes. 1 0 Feb. 05, 2024
Site is in BETA!found a bug?