0 votes

Heya,

I am having trouble getting a Variant to correctly be passed to a native library.

I have a this method that goes like this:

void My::print(const Variant &p_value) {
std::stringstream test;
test << p_value.get_type();
Godot::print(test.str().c_str());
}

I am registering it like this:

register_method("print", &My::print);

When I call it from a GDScript like this:

My.print(Vector2(10,10))

I get the following output:

0

Anyone have an idea what I am missing? I have already checked how other methods (like json) do this, and it does not look different.

asked Jul 24, 2018 in Engine by Beliar (19 points)

1 Answer

0 votes
Best answer

Okay, the Problem was fixed by changing the method to this:

void My::print(Variant p_value) {
std::stringstream test;
test << p_value.get_type();
Godot::print(test.str().c_str());
}
answered Jul 25, 2018 by Beliar (19 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.