Open mastern2k3 opened 5 years ago
I discovered that if you use the generic .Get func(property String) Variant
and .Callv func(method String, argArray Array) Variant
you get the normal behavior, e.g.:
// len := anim.GetCurrentAnimationLength()
len := anim.Get("current_animation_length")
@ShadowApex can you maybe make sense of this?
i ran into the same issue. i'm going to see if i can get to the bottom of this. looks like it might be a mangling of arguments
just an update. the fix is to cast float arguments into C.double
when constructing the argument array when calling ptrcall
. This needs to be done for all floating point arguments regardless if the argument is documented as just single precision C.float
. Because this project seems to be abandoned, I've implemented the fix in my implementation of godot-go here https://github.com/godot-go/godot-go
you can see an example of the use of the function here: https://github.com/godot-go/godot-go/blob/master/test/pkg/gdnativetest/object_player_character.go#L161
you can look at the code generation here: https://github.com/godot-go/godot-go/blob/master/pkg/gdnative/classes.gen.go. You'll have to search for func (o AnimationPlayerImpl) Play
to find the implementation.
@pcting Nice Job! Was trying to figure this out myself to produce a fix but failed. What was your investigation process? how did you understand this?
my best reference was looking at the godot-cpp project. it also helped asking questions in the gdnative-dev room on the discord servers. i originally decided to create my own godot-go library to better understand cgo, gdnative, and nativescript.
it's a very difficult process as the only real tool to debug cgo is gdb as lldb gets confused when stepping through the go code. i could probably write a medium article on the hurdles and hardships i went through to get the project where it's at.
Would love to help you maintain a new godot-go repo. My experience with cgo is pretty weak and I would love to learn how to use gdb and lldb in this context. I already have some fix enabling compilation to arm on a fork, I'll adjust it and PR https://github.com/godot-go/godot-go.
Description
I started using godot-go recently and I gotta say - the work you've done here is amazing and I'd love to contribute and make it more stable - that saying, I have a problem I can't figure how to solve.
The bindings work fine but for some reason, the
AnimationPlayer
element is behaving odd. Calling.Play()
or.GetCurrentAnimationLength()
seem to behave as if thegd.Real
parameters and return values map to 0.Things I've tried doing with no success:
.Play()
onAnimationPlayer
andAnimationPlayerImplementer
to acceptgd.Float
instead ofgd.Real
gd.Float
underlying type befloat32
instead offloat64
I've created an example project repo for convenience: https://github.com/mastern2k3/godot-go-animtest
Would love help on this or maybe a new thread to follow, thanks in advance!
Details
go version go1.11 linux/amd64
3.1.stable.official
master branch "1746202"
Linux Mint 19.1 linux/amd64