0 votes

I was able to receive _ready and _process in my GDNative C++ class already and was trying to capture InputEvent in _unhandled_input. The method is declared as:

void _unhandled_input(InputEvent event);

And the compilation failed with errors. Compiler (MSVC) seems to complain about not being able to implicitly convert Variant to InputEvent. I assume this is because GDNative script try to pass every parameter of the function using Variant.

So, what is the correct way to define _unhandled_input method inside GDNative C++?

asked Feb 8 in Projects by logicor (28 points)

1 Answer

0 votes

Hello logicor,
Haven't tested this myself, so take it with a grain of salt. Usually those "can't implicitly convert Variant to X" errors come from the fact that Godot passes everything as reference behind the scenes.

Try changing the prototype of the function to :

void _unhandled_input(godot::Ref<godot::InputEvent> event);
answered Feb 8 by TheFamousRat (263 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.