Where can I improve my knowledge of GDScript?

The GD Script video was the second in the Godot series, the first was the platformer.

1 Like

I might actually close this topic since I’ve gained lots of answers and ways I could learn the engine more, So this forum should have just been about YouTube video suggestions I could have used instead but, oh well.

I’ll leave this topic up for any last-minute suggestions that could help make my research easier, then this topic will be finished up and closed.

Thanks to everyone who helped me out and commented on this forum, your help is very much appreciated, wish me luck in this Godot journey and I wish you all the very best in your Godot journeys as well :smiley:

Vectors look into linear algebra.

Collision look into physics.

Gdscript is pretty simple. (this is the complete list)

Classes (Inheritance, constructors, super)
Functions (static, lambdas, Callable)
Signals
Coroutines (await)
Variables (static, constant, literal, reference)
Strict typing (var a : int = 0 ; a = 5)
Dynamic typing (var a = 1; a = “hello”)
Logic operations (&, |, etc.)
Math operations ( +, -, etc. )
Assignment ( a = b )
Comparators (<, >, ==, etc.)
Branching ( if/else/elif, ternary, match)
Looping (for,while)
anotations (@: RPC, exports, tools)
Enumeration
casting ( var b = a as float )
setters/getters
grouping ( “( a+b)”)

The rest is more about data types and not really related to the gdscript language, and all of these concepts are pretty universal. Once you get to objects those are more Godot specific class structures.

Variant ( Godot’s “any/dynamic” type )
Int
Float
Boolean
Vectors and matrixes (basically 1d and 2d arrays)
Array
Dictionary
String
Object ( the base class )
Resource
Node
Etc…

1 Like

@pennyloafers Thank you very much! :smiley: Now I have an actual clearer idea on what I need to learn in GDScript.

Also could any one help me understand this code I’m using in my pong game (Credits to @sven for giving me the code in my first and previous topic)

extends CharacterBody2D

var speed = 300
var movement = Vector2(0, speed)

func _physics_process(delta):
	
	var collision = move_and_collide(movement * delta)
		
	if collision:
		if collision.get_collider().name == "Paddle":
			speed = -speed
				
				
			var diff = collision.get_collider().position.x - position.x
				
			var new_movement = Vector2(-diff * 5, speed)
				
			movement = new_movement
		elif collision.get_collider().name == "Borders":
			movement = movement.bounce(collision.get_normal())
2 Likes

Comments inlined

I was looking at the code and saw this

var diff = collision.get_collider().position.x - position.x

This I think is ment to find where the ball meets the paddle to allow you to hit hard angles of the ball is closer to the edge, but it is using the x axis.

If the paddles are left side and right side of the viewport. This would make the left paddle always shoot very slightly down, and the right shoot very slightly up.

I think it should be:
var diff = collision.get_collider().position.y - position.y

This would allow you to control the ball direction depending on where you make it land on the paddle.

1 Like

Or yes, another question I wanted to ask, how do I fix the bug where when the ball hits the middle of the paddle, it’s slow, but on the edges, it’s fast. I know you’ve already shown the code for it, but I don’t really have any specific instructions on how to fix it.

Also thanks for adding comments so I know what each line of code does, I’ll copy this to my project and read it more thoroughly from there :grinning:.

1 Like

Also I tried the position.y instance instead of the position.x, but it made the ball slower than it’s previous speed and made it always go left when hitting the paddle. would it work if I just use the bounce and normal function for the paddle as well?

1 Like

And do you happen to have any knowledge on Skeleton2d?

Strange? how am I not able to edit my previous comments anymore? Is this normal?

1 Like

you have started to ask off‑topic questions in this thread.
you should make a new thresd for every topic.

also, asking your questions properly is just as important a skill as using the game creation tools

Now that you say it, I think It’s time I actually close this topic since my answer has already been solved with a post by @pennyloafers, Thanks to everyone who helped out in this topic, I’ll see you all next time.

Starting small sounds like a good approach.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.