#how to make Variant type "known"
10 messages · Page 1 of 1 (latest)
You probably can't
okay, is there a chance anyone else has a more certain answer?
Does this help?
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/static_typing.html
In this guide, you will learn: How to use types in GDScript, That static types can help you avoid bugs. Where and how you use this new language feature is entirely up to you: you can use it only in...
I'm pretty sure you can just var gravity : float = foo();
But probably in this instance project setting will return a variant because its unknown which part of the settings you're accessing so it could be anything
I am aware of how static typing works
yes, I have tried : float =, := ... as float (which works for casting node references) but neither show that line as type safe
clamp also causes a similar issue as there are no generics to define its return type
it can't be "type safe" in that circumstance, because the type returned is Variant. all you can do is perform checks (in _ready or elsewhere) to handle it as a different type, via casting or whatever other method. same thing for null checking basically
tl;dr C# superiority, where type matters all the time