A year and a half studying programming and Godot. I saw in a video that this set should work, but it doesn’t work for me. I don’t really understand how get and set work.
extends RigidBody2D
@export var texture:CompressedTexture2D:
set(value):
texture = value
$Sprite2D.texture = value
It tells me that texture is null. How can I make this work?
What specifically are you trying to set? in the documentation it says you need a ‘get’ function as well before a set function, because both will be called.
also, this line:
set(value) texture = value
Godot is expecting two argument for the set function. (for example, it says “milliseconds = value * 1000” in the documentation. value and 1000 are the arguments.) so i added a x1, and im getting no errors. Ill give you the code so you can try to see if it works for what you need
extends RigidBody2D
@export var texture = CompressedTexture2D:
set(value):
texture = value * 1
$Sprite2D.texture = value