Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probelm with AnimationPlayer (suspecting gd.Real does not translate well) #47

Open
mastern2k3 opened this issue Mar 30, 2019 · 6 comments

Comments

@mastern2k3
Copy link

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 the gd.Real parameters and return values map to 0.

Things I've tried doing with no success:

  • Editing .Play() on AnimationPlayer and AnimationPlayerImplementer to accept gd.Float instead of gd.Real
  • Making gd.Float underlying type be float32 instead of float64

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 go version go1.11 linux/amd64
Godot version 3.1.stable.official
Godot-Go version/commit hash master branch "1746202"
OS Linux Mint 19.1 linux/amd64
@mastern2k3
Copy link
Author

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?

@pcting
Copy link

pcting commented Jan 20, 2020

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

@pcting
Copy link

pcting commented Sep 27, 2020

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.

@mastern2k3
Copy link
Author

@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?

@pcting
Copy link

pcting commented Sep 29, 2020

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.

@mastern2k3
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants