Introducing Dragonfly Cloud! Learn More

Question: Does Godot use Python?

Answer

No, Godot does not use Python as its primary scripting language; instead, it uses a Python-like language called GDScript. GDScript is designed to integrate seamlessly with the Godot editor and is tailored specifically for the high-level node-based architecture of Godot.

Here's an example of how GDScript code looks:

extends Sprite # Member variable var speed = 100 # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): var input_vector = Vector2(0, 0) input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left") input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up") input_vector.normalized() position += input_vector * speed * delta

This example shows a _process function that moves a sprite based on user input. The syntax should be familiar if you are used to Python but GDScript is a separate language with its own quirks.

However, there is also an option to script in other languages through plugins or modules. For example, there is a plugin called "GodotPython" which enables scripting in Python. These are community-driven projects and are not officially maintained by the Godot Engine developers. Here is an example of how this might look if you were to write a script using the Python plugin:

from godot import exposed, export from godot.bindings import * @exposed class Player(Node2D): @export var speed = 100 def _process(self, delta): input_vector = Vector2.ZERO if Input.is_action_pressed('ui_right'): input_vector.x += 1 if Input.is_action_pressed('ui_left'): input_vector.x -= 1 if Input.is_action_pressed('ui_down'): input_vector.y += 1 if Input.is_action_pressed('ui_up'): input_vector.y -= 1 input_vector = input_vector.normalized() self.position += input_vector * self.speed * delta

Regardless, the official and most optimized way to script in Godot is by using GDScript.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.