Set / Get functions in Godot 4! | Quick Tutorial

preview_player
Показать описание
Hey everyone!
In this quick video, I'll go over how to setup and use setter and getter functions in Godot 4!
Thanks for watching!

This video was recorded in Godot v4.1.1

Timestamps:
-----------------------------
0:00 Intro
0:22 Code Snippet
0:28 What is a Setter/Getter?
0:52 Example Setup Code
3:59 Other Notes
4:42 Outro - Thanks for watching! :)
-----------------------------

Various Links:
-----------------------------
Instagram: @queble_game_dev
Twitter: @Queble__Games
YouTube: ... :O
-----------------------------
Рекомендации по теме
Комментарии
Автор

Subbed for 0:23. Still watching the whole vid. BASED

DayumAli
Автор

Thanks for the tut, im having a hard time wrapping my head around this concept, but your video has cleared it a little for me 🎉

juliangutierrez
Автор

This has been the clearest video so far for a newbie like me who has never coded a game! I've tried several tutorials to wrap my head around set and get. SUBBED!!

olson
Автор

Appreciate the "just the code" section! I'll use it, so here's a comment and a like in return

Heulerado
Автор

you can also write: *var health: float = 100.0 setget _set_health, _get_health* (but you need to mind the order)

Muphet
Автор

Shorter syntax:
var hp = 10:
set(value):
hp = value
get:
return hp

VaunaKiller
Автор

Hey man! Loved the video thank you so much for it! Could you tell us how you made Godot look like that? I just love the color scheme you got going on!

Majewstic_
Автор

Just found this. Great video. Could you explain the setter parameter a bit more? What does “new_value” do since there’s no value there?

NocturnalPenguin
Автор

Is the checkerboard at the bottom where the taskbar was? You can toggle full screen by pressing Shift + F11. Great video, btw :)

timeSlidrGaming
Автор

im here by almost complete chance... I was looking for a tutorial for the set() and get() function for variables... but now that I'm here this looks massively useful, but I just don't know how it would be applicable? Why not just reference the variable itself? And if you want to run a function then why even bother linking it back to the variable it's changing? It would work reguardless wouldn't it?

ISamAtlas
Автор

It doesn't work for detecting changes in array ?
The docs says it does but this exact same code does nothing for arrays.
Using Godot 4.2

EthernalOynuyor
Автор

I get an error saying "function cannt be used as setter because of its signature". Can't seem to find a fix through google. Can you help?

VoiceChattin
Автор

I don't understand how can you call another function that it's not going to be available when initializing the variable heatlh. Won't Godot try to access _get_health and give an error because it has not been initialized?

serghonest
Автор

very small complaint, the voice is very low try to get it higher so everybody can hear next time . and nice tutorial

JebaliJihed-gc
Автор

This code will works without set and get parts in variables line?

codewithmax