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

ClassDB::bind_method not properly casting Variant to Node #966

Closed
WildRackoon opened this issue Dec 16, 2022 · 2 comments
Closed

ClassDB::bind_method not properly casting Variant to Node #966

WildRackoon opened this issue Dec 16, 2022 · 2 comments

Comments

@WildRackoon
Copy link
Contributor

I reproduced the error in this forum issue : https://godotforums.org/d/31691-how-to-bind-a-function-with-a-node-as-parameter

Methods using a Node as parameter works in Godot internal modules, but not when using godot-cpp in a GDExtension.

void MyClass::my_func(godot::Node *p_node) {
  // ...
} 

void MyClass::_bind_methods()
{
  godot::ClassDB::bind_method(godot::D_METHOD("my_func", "node"), &MyClass::my_func);
}

Outputs following Templates errors:

godot-cpp\include\godot_cpp/core/binder_common.hpp(89): error C2440: 'return': cannot convert from 'const godot::Variant' to 'T'
        with
        [
            T=godot::Node *
        ]

I can't figure how internal modules obtain this casting behaviour, any ideas ?

@DmitriySalnikov
Copy link
Contributor

Probably this PR can help #950

@zhehangd
Copy link
Contributor

The latest version does not seem to have this problem anymore.

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

3 participants