See all glossary terms

Property, member variable

A property, which we also commonly call a member variable, is a variable attached to and stored in an object, an entity that groups data (variables) and functions.
In Godot, nodes have many properties. Let's take the Sprite2D node for example:
  • Its texture property stores the image displayed by the sprite.
  • Its position property stores the position of the sprite in the game world.
  • Its visible property stores whether the sprite is visible or not.
In a script file, in GDScript, whenever you define a variable outside of functions, it is a property (you can also call it a member variable). For example, this script adds a health property to any 2D node it's attached to:
extends Node2D

var health := 100

The technical difference between property and member variable

Properties and member variables are closely-related programming concepts: They're both variables attached to an object, and we often use these terms interchangeably.
The nuance between them is that a property builds upon a member variable and reads and writes data through an extra mechanism, typically a getter and a setter function. In Godot, when you define a member variable, under the hood, Godot reads and writes to it through a getter and a setter function. So technically, all member variables in Godot are properties.