Koro422
Koro422

Reputation: 1

What does func _physics_process(delta), move_and_slide(), Vector2() and do in gdscript?

I'm just started learning to program because I want to learn how to make a game. I choose the Godot engine to start making games but I can't understand what anything does. I have only understood the concept of variables and constants. I'm watching a couple of tutorials and copying exactly what the people in the video are doing but I don't just wanna copy and not understand anything, so could you please tell me what the above things even do?

Upvotes: 0

Views: 3653

Answers (2)

magmasloth64
magmasloth64

Reputation: 1

I was just looking into more information on what the _physics_process(delta) function does and came across this thread (kajus_the_dwarf's answer was very helpful) I just had to chime in and note that about roughly this same time you had asked this question last year, I was in a very similar place. I have plenty of 3d experience but was a complete noob at programming, and because of this many of the godot tutorials went way over my head. I was able to copy the tutorials step-by-step but struggled to wrap my mind around what was actually happening. What has helped me immensely, and what I'd highly recommend for you, is to follow some beginner python programming courses. I've heard Godot's language gdscript described as pythonic C#, it is a unique and highly intuitive programming language that draws many features from C, C++, and C# but follows a simple python syntax. Studying one of the C languages would certainly help in further boosting your understanding, but I would personally suggest studying python because even though godot doesn't utilize all of pythons features, when you're programming in gdscript it feels like you're essentially programming in python.

What I did was downloaded a free app on my phone called "sololearn" which makes it really easy to learn any of the major programming languages of your choosing in a structured and enjoyable experience. I followed the python beginner and intermediate courses on that app and now godot makes so much more sense to me. I would also recommend the youtuber "Corey Schafer" who has some of the best beginner tutorials out there thanks to his solid understanding and engaging teaching style.

so yup, that's my advice from a fellow student on this godot adventure; study python!

Upvotes: 0

kajus_the_dwarf
kajus_the_dwarf

Reputation: 11

The physics process is called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the delta variable should be constant which isn't the case if you just call _process(delta):

Vector2() is just a 2d vector, the first parameter for the x axis, the second for y. You can use it also as an boolean, Vector(0,0) always returns false, while every other point returns true.

move_and_slide() was designed as a special case, because a common use case was to calculate a slide vector along the collision. However, because it slides, it's possible for there to be more than one collision in a frame (think when you hit a corner between the floor and the wall. For this reason, it can't return a collision, so you need to use the get_slide_collision(). So it handles for example how your character react if he collides with an object.

Upvotes: 1

Related Questions