Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float in Godot 4
A static function was called with an argument whose type cannot be converted to the parameter's type. Vector2.from_angle(data.angle), where data.angle is the String "1.5" from JSON, stops with Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float; convert the value first, Vector2.from_angle(float(data.angle)).
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
When a static function of a built-in type such as Vector2 is called, the arguments are checked against the types the function declares. If one cannot be converted, the call fails, and the VM names the function, the type it belongs to, the argument's position counted from 1, the type it got and the type the parameter expects.
The same message is built for static functions of engine classes, with the class name after in type, from the second static call path in the VM.
It is a runtime error: the script parsed, and the error appeared when the line ran. The function that made the call stops there, so the print("after") below it never ran, as the output shows.
JSON.parse_string() returns a Variant, so the analyzer does not know that data.angle holds a String, and the call is checked only when it runs.
More on this: How to parse JSON in Godot 4: JSON.parse_string()
Reproduce it
An angle read from JSON, stored as a string, passed straight to Vector2.from_angle(), which takes a float.
More on this: How to save and load a game in Godot 4: FileAccess
extends Node
func _ready() -> void:
var data = JSON.parse_string('{"angle": "1.5"}')
var direction := Vector2.from_angle(data.angle)
print("after")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float.
at: _ready (res://answers/invalid-type-in-static-function-cannot-convert-argument/repro.gd:5)
GDScript backtrace (most recent call first):
[0] _ready (res://answers/invalid-type-in-static-function-cannot-convert-argument/repro.gd:5)Fix it
Convert the value to the parameter's type before the call. float() converts a String the same way String.to_float() does.
More on this: The function signature doesn't match the parent. Parent signature is "…" in Godot 4
extends Node
func _ready() -> void:
var data = JSON.parse_string('{"angle": "1.5"}')
var direction := Vector2.from_angle(float(data.angle))
print("direction ", direction)
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
direction (0.070737, 0.997495)Run this fix with your agent
Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.
More on this: Invalid argument for "…()" function: argument 1 should be "…" but is "…" in Godot 4
My Godot 4 project prints this error: "Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float.". Find where it comes from and fix it. A static function was called with an argument whose type cannot be converted to the parameter's type. Vector2.from_angle(data.angle), where data.angle is the String "1.5" from JSON, stops with Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float; convert the value first, Vector2.from_angle(float(data.angle)). Then run the game headless and check that Godot's output no longer shows it.Verified 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 6 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: gdscript_vm.cpp line 179, the message, gdscript_vm.cpp line 2143, static functions of built-in types, gdscript_vm.cpp line 2189, static functions of engine classes, Vector2.from_angle in the class reference, JSON.parse_string in the class reference, float(String) in the class reference.
Questions
- Why didn't the editor flag the call?
- JSON.parse_string() returns a Variant, so the type of data.angle is not known until the line runs. The repro parsed and failed only when the line ran.
- Did older Godot versions print a different message?
- Godot 4.2 builds the same text: Invalid type in static function '…' in type '…'. Cannot convert argument N from A to B.
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free