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?
Other Common Game Engines Questions (and Answers)
- Can You Use C# in Unreal Engine?
- Is Unreal Engine Open Source?
- Can Unreal Engine make 2D games?
- Does Unreal Engine Use Python?
- What Language Does Unreal Engine Use?
- Does Unreal Engine Use JavaScript?
- Does Unreal Engine work on Linux?
- How Do I Uninstall Unreal Engine 5?
- Is Blender or Unreal Engine Better?
- Does Unreal Engine Work on Mac?
- Why Is Unreal Engine So Laggy?
- Can I Run Unreal Engine 5 Without a Graphics Card?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost