Closed Ullanar closed 4 months ago
Thanks for sharing your experience here @Ullanar, you can convert the variant into a gd.Float
with a type assertion, ie.
var f = godot.Variant(gd.Float(3.14))
fmt.Println(f.Interface(godot).(gd.Float))
I've also just added a commit introducing methods that will do the same thing for value types (similar to reflect.Value
, they will panic if the type doesn't match).
var f = godot.Variant(gd.Float(3.14))
fmt.Println(f.Float())
For now there are hard to work with varians due to lack of documentation and utility methods
For example now trying to make simple 3d character controller. And ofc we need gravity setting which is
Variant
.And then we need, for example, handle falling state. Which means what if we are not on floor we need to work with
Velocity.Y
and common case isSo delta is
gd.Float
and gravity isgd.Variant
.I spend several hours trying to understand how to cast them, searching through source code and still cant understand how to correctly work with math here
Variant.Interface()
returnsany
but then how we can cast any and FloatSo the issue is:
Even so, thank you so much for your great work. It was more than year since we are doing smth with godot and using Go goroutines in Godot it is the best birhday gift which we can even have