If you paused the video and are looking in the comment for an explanation of why he sets angular_speed equal to PI and then still use PI instead of angular_speed in the code: he forgot, he sets it right later near the end. I found it really distracting as I was trying to figure out what I was not understanding up until he set it right. With that said it's an excellent series so far.
@@thechartheorist7715 think about it like doing x = x + y. its essentially the same. remember that we don't use = in programming like we do in math, = assigns a value to something, not set it equal to. so this wouldn't work like an algebraic equation, in which y would have to equal 0, but instead would make the new value of x the sum of y and x.
i thought it was too lol. it was recently when a friend of mine said oh ik them! and i'm like yeah, its the official youtube i should think you would! only to be corrected that it actually isnt the official lol
This is very late, but for those who may be confused by the "Vector2.UP.rotated(rotation)" portion at 16:00, Up is relative to the position of the node, not the scene itself. So since the Godot head started upright, 'up' is always toward the top of its head.
I really don't like Godot's naming conventions. "rotated" sounds too much like a boolean variable, not a function. It also doesn't really describe what the function does by just reading the name.
@@vantalk8263 Correct! I want to summarize what I was confused by too for this section. 1) As vantalk said, Vector2.UP is relative to world space. This means that moving the character position with Vector2.UP will always move it towards the top of the screen no matter the rotation of the sprite. 2) I was very confused by the rotated function. In simple terms, rotated will provide a new coordinate based on the angle of input. Example: Vector2.UP is Vector2(0,-1) because up is negative in godot's 2d space. If you wanted to change the angle to be slightly northeast, by like 0.05 radians, the function Vector2.UP.rotated(0.05) creates a new value of Vector2(0.049979, -0.99875) What does that new value do? If you change your characters position by this new rotated value, it will move the character in the up and slightly right direction. Your character is still moving by 1, but if we imagine Vector2.UP to be 12:00 oclock, then the hour hand for the new coordinate will be pointing at 12:02. This makes the rotated function, as aden said, move relative to the sprite itself instead of the world. The circular motion is occurring because the character is getting a new angle of rotation, then moving by 1 unit in the direction it is facing. Sorry if I overexplained something others already understood. I just wanted to share what I had to do to fully understand what was happening.
On our website, you will find extra details I couldn't cover in the video, like what's that thing about properties, objects, etc.: www.gdquest.com/tutorial/godot/learning-paths/getting-started-in-2021/chapter/8.your-first-script/ If you have a question about this video, please write comment below the video. I'll do my best to answer them, although I can't promise to answer every question.
I absolutely love this course! The feeing of creating something as simple as an icon rotating was so satisfying. After the video I decided to also have the icon back up when you press the page_down key and for some reason that got me really excited. Thank you so much again for creating these beginner videos to help those who'd like to get into creating videogames!
Great tutorial, friend. After finishing it, I messed around with the code a bit and figured out how to make the Godot icon slow to a stop after letting go, like it's an ice level or something. Really fun.
I've hit summer vacation and decided to start learning Godot as my first not visual scripting experience. This series has been super helpful so far, and I decided to go one step further and try to make the godot icon move backwards at half the speed. Figured it out pretty easily; feel weirdly proud on that one
How this can be???!!! Why this channel hasn't 1 million subscribers yet???!!! Guys, you're saving my gamedev dream! Thank you so much for this incredible course! I think EVERY framework in the world should have a course like this one. Really, thank you I hope this channel reach 1 million subs soon.
This language is brain dead easy and I love it. Much nicer to use that C++, and it is great that you can write it in the engine and it recognizes what you type with no fuss. I am happy.
To be honest for me the C++ is much more logic and e.g. passing values (not functions), e.g. poistion values between scenes are a nightmare for me as in C++ is quite logic and easy
Super fun tutorial! You slowly helped us build this little movement game, by showing us the building blocks of it. I felt immense gratification when I paused the video, and realized I could uncomment the previously commented movement code and added another if statement to detect an up press :) keep up the great work!
This is a good tutorial for showing how an experienced programmer would approach this task, but I feel it doesn't quite do a great job of explaining what each of the constituent parts are. Specifically, for anyone like me who might not fully understand what that line "velocity = Vector2.UP.rotated(rotation) * speed" is doing, here's a really granular breakdown... Basically it does a big math problem that does the following steps: - First, it gets Vector2.UP (a pre-defined value consisting of (0,-1), which gdscript uses as a shortcut to save typing). - Then, it uses a METHOD called "rotated" to multiply that by the argument in parentheses - In this case, that argument is 'rotation', which is a gdscript PROPERTY which refers to the current rotation of the sprite. - Lastly, it throws in the speed variable we created, as an overall multiplier. (The reason this is included is so we can easily adjust the movement speed by changing a single variable, up at the top of the script.) So it does that big math problem, and then it assigns the result of all that to the "velocity" variable. That means, when it's all said and done, "velocity" holds a value that could be described as "the direction that the top of the sprite is currently facing, times a custom speed variable". You could rename this variable heading_and_speed, if that makes more sense. The last line of code here, "position += velocity * delta" then simply tells the computer: "Change the position of this sprite by incrementing it slightly. Increment it in whatever direction the sprite's top is currently facing, and do so at the speed I've given you. Do that once per frame."
These tutorials have been so helpful! I been starting to study how to use Godot for like three days, i just finished doing this part of the tutorial I felt so proud of myself when i managed to found a way to make the sprite go backwards if the Down key was pressed, it wasn't anything special really, but managing to make it myself based on what i learnt from the video felt so nice ^^
Thank you for the tutorial! I know it's hard to go step by step and explain every little feature and function but you guys are making it so that we're not just blindly following a tutorial but instead, understanding the tools we are using, making it easier to recall and use on our own in the future. Thanks for all the hard work!
@GDQuest This is probably the most user friendly programming tutorial ever made. You explain e.v.e.r.y.t.h.i.n.g in details, which helps a lot to understand this seemingly non-sensical jargon. Congratulations, this is very valuable! And thanks for making this. :)
I cant thank you enough for these tutorials. I used to think coding was intimidating but these tutorials made it seem easier than I thought it would be.
Thank goodness for this tutorial! I've tried for days to understand how to pan a huge sprite in a Viewport to act as a map and had no idea the code had to be attached to the Sprite child of the viewport!
Godot has so far been the best way to get into Game Dev for me! :D I tried Unreal but it's just, massive and didn't felt as beginner friendly as Godot to me. Plus, these official tutorials are absolutely amazing!!!! I have mostly worked with non graphical coding through college so now I'm finally looking forward with working with Godot.
Love the timestamps! They're great to have for tutorial videos like this one. A little request here - could you turn on community contribution for the captions?
Thank you for the clear explanations! Also, couldn't have understood it all without Godot's tutorials on Vector Math & Matrices. Tried in the past with other tutorials and understood nothing.
Thank you so much for this course! I've been out of serious software development for over 15 years now barring some PHP and HTML work on our company website and I decided to get back into game development via Godot. I'm actually of the era of developing in C using Allegro and SDL and this modern approach with UI-based middleware takes some getting used to, but this lesson gave me the opportunity to develop the example code further until I had a basic vehicle physics engine in place, complete with acceleration, momentum, resistance and a basic "return to home" function, as well as some rudimentary debugging code, since I haven't got to collision or boundary detection yet :)
That was a fun tutorial, I'm so grateful for the search help and built-in definitions. They make everything painless without having to resort online for finding different functions, they also made the tutorial more digestable. It was fun expriementing and adding my own things to it, all of which is very simple but it's just the thrill of figuring things out on my own cause I'm a huge beginner and rarely ever touch code, can't wait to learn more about gdscript.
how does the rotation and position works? why do we need to keep them in the code? EDIT: ctrl+clicked the thing and it came up. rotation and position is a part of Node2D thingy. I get it now. But please do correct me if I'm wrong :D
Thanks! This has been really helpful. I have recently started using Godot instead of the Javascript Canvas and I have been looking for a good scripting tutorial.
at first it was easy, but then it gets faster and faster and faster 😵💫 hehehe, my brain is melting as I am no programmer. I also found that the interface of godot changed a bit, like stuff where he showed on the input map is no longer exist in 2023 / 2024 version unless you checked "Show Built in Action" 😄 Never the less I am grateful that you provide this intro lesson🙏🙂
Hi! Try the free interactive app instead if you haven't. It's called Learn GDScript from Zero and you can find it on GDQuest.com. It's up to date for Godot 4 and you can learn at your own pace.
i also added a third if : if Input.is_action_pressed("ui_left") && Input.is_action_pressed("ui_right"): direction = 0 to avoid when player presses both, it would ALWAYS turns right as that is the last command, if a player presses both, it shouldnt rotate at all imo
This is my first Godot project! I am learning Unity and I am having fun with it. But I am studying python and like that the syntax is similar to python.
I'm at around 9:52 when you first test the rotation script but my sprite instead of spinning in place, is moving around the screen, almost orbiting something in the top left corner extremely quickly? my code looks like this: extends Sprite var angular_speed = PI func _process(delta): rotation += angular_speed * delta (also its just the sprite node with the icon.png as the texture) Edit: i have no clue what i did but i re-wrote it the exact same way with the exact same code and it worked..
I encountered this problem too. This happens because in the "2D" screen, the sprite is kept in such a way that it is displayed at the top left of the screen which causes it to disappear in the debugger. All you have to do is, go to the "2D" screen and drag the sprite a little to the bottom right from the origin ( the point where the axes meet) and then run the scene (F6)
I hope text editor in Godot 4.0 Will be greatly improved. Cause coming from Rider, or even VS code is a lot of pain. No renaming, only Search & Replace and if you forgot to save your script before doing this operation, you will lose all your unsaved changes… This was a disaster for me. Haven’t seen text editor with limitations like there ever. And thanks for the tutorial! It is nice to have an easy entry point to touch the new engine as quick as possible
ive always wanted to learn how to code and your doing it great godot is a great game engine and you have probably taught so many others and it feels alot less like work than fun so thank you.
Need video dedicated to explain about the use of delta. I couldn't understand the explanation from this video, nor any example was shown . I had to look at other channel to understand the concept.
GDScript is a lot easier than C++ lol also if you wanna do full arrow keys movement just add under Var velocity : if Input.is_action_pressed("ui_down"): velocity = Vector2.DOWN.rotated(rotation) * speed
Thank you for you amaizing tutorials I still don't understand what delta does under the hood, what are delta's actual value? Why for instance when I use just 'position += Vector2(100.0, 100.0)' and click run, I cannot see the Sprite, I assune it went somewhere very quickly but I don't understand why
Delta is the time elapsed between two frames in seconds, typically a small fraction of a second. If you move 100 pixels every frame like you did, with your game running at dozens or hundreds of frames per second, your object ends up moving too fast.
hy , great video i know im a bit late for a question but is it the same to change a property like position using position directly or from position setter the same as the position getter
Okay so I followed this step by step! And the part at 7:30 - 9:52 where your logo is spinning in a small circle... mine didn't happen that way. What mine did do was a much larger circle that made the logo go off the screen. Is there something wrong that I am doing??????????
Thanks for this wonderful tutorial Any chances you guys will make this same thing but with GDNative and another language? Its really hard to understand and there are people who'd prefer to work in C if they can
Thanks very much for the effort your putting on explaining but ⚠⚠⚠ I suggest a simple animation would make for a great addition that will make understanding instant
I understand why it would be easier to understand by creating a velocity variable to hold our velocity calculations in before translating them to motion, but to me, that feels like it's just wasting processor power having to create a variable, using it once, and then destroy it afterward. Even though computers are blazing fast these days, it feels like this extra memory allocation would compound to a slower game. Should I really concern myself with optimization this much?
Interesting I followed along and my character smoothly turns to the left and I can hold it down. but to the right it only turns per click and not smoothly when holding it down. I also used "_delta" instead of delta because it wouldn't let me without the "_" but overall I learned a lot and thank you for taking the time to teach this
So I'm going through this tut. and I wrote the code like you have, but I did "angular_speed" instead of "PI" on line 6, and when I typed in what you have for line 7 I got an error about vector2. I looked around to see what the problem was like spelling and punctuation but still the error but when I deleted the line and retyped it in exactly the same it worked(sorry don't remember the the error exactly, wait found it = Parse error: the method "vector2" isn't declared in the current class). Just wondering what happened there. Did it not update when I finished typing the line and still displayed the error?
I'm really confused by the math on this... It seems like we are multiplying the speed multiple times by delta why are we not getting greater and greater numbers pumping out?
the _process function affects the sprite coordinates - they change every frame, but the variable speed does not change, it is always 400, as indicated at the beginning of the code