Quat in Godot 4: it is Quaternion now
By Eduardo Orellana · Updated
Quat is called Quaternion in Godot 4, and Basis.get_rotation_quat() is get_rotation_quaternion(). In a Godot 4 project, Quat(axis, angle) fails to parse with Function "Quat()" not found in base self. Did you mean to use "Quaternion()"?.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
Quat was a built-in type, so Godot 3 code calls it like a constructor, Quat(...). Godot 4 renamed the type, and the analyzer reads the old name as a call to a function that does not exist; because the name is in the renames table, it suggests the new one.
Quaternion(axis, angle) still builds a rotation from an axis and an angle in radians, and slerp() still interpolates between two rotations. A Node3D's quaternion property reads and sets its rotation as one.
Reproduce it
A Godot 3 rotation built with Quat(), in a Godot 4 project.
extends Node
func _ready():
var q = Quat(Vector3.UP, PI / 2)
print(q)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Function "Quat()" not found in base self. Did you mean to use "Quaternion()"?
at: GDScript::reload (res://answers/quat-in-godot-4/repro.gd:4)
ERROR: Failed to load script "res://answers/quat-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
A quarter turn around Y as a Quaternion, applied to a vector.
extends Node
func _ready() -> void:
var q := Quaternion(Vector3.UP, PI / 2)
print((q * Vector3.FORWARD).snappedf(0.001))
print(Quaternion.IDENTITY.slerp(q, 0.5).get_angle(), " rad halfway")
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
(-1.0, 0.0, 0.0)
0.78539770841599 rad halfwayVerified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: [gdscript_analyzer.cpp line 3767, the message with its hint](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L3767), [renames_map_3_to_4.cpp line 1435, Quat to Quaternion](https://github.com/godotengine/godot/blob/4.7.2-stable/editor/project_upgrade/renames_map_3_to_4.cpp#L1435), [Quaternion class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Quaternion.xml).
Questions
- How do I get a Node3D's rotation as a quaternion?
- Read its quaternion property, or basis.get_rotation_quaternion().
- Why use a quaternion instead of rotation_degrees?
- Interpolating between two orientations with slerp() takes the shortest path and avoids gimbal lock.
Related
- PoolStringArray in Godot 4: it is PackedStringArray now
- Spatial in Godot 4: it is Node3D now, and translation is position
- Every verified Godot 4 answer
- Function "…()" not found in base self in Godot 4
- SpotLight in Godot 4: it is SpotLight3D now
- KinematicBody in Godot 4: it is CharacterBody3D now
- Path in Godot 4: it is Path3D now
- Cannot get return value of call to "…()" because it returns "void" in Godot 4
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free