Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lafleur |
In gdscript when writing a bot to control a character I use to do
var _up = InputEventAction.new()
func _ready():
_up.action = "left_move_up"
_up.pressed = true
func move_up():
Input.parse_input_event(_up)
In GdNative I tried many variations around
class Example : public Node2D {
GODOT_CLASS(Bot, Node2D);
private:
Input *_input;
InputEventAction *_up;
public:
void _ready();
}
void Example::_ready() {
_input = Input::get_singleton();
_up = InputEventAction::_new();
_up->set_action(godot::String("left_move_up"));
_up->set_pressed(true);
}
void Example::_process(float _delta) {
InputEvent *ev = Object::cast_to<InputEvent>(_go_up);
if (ev) {
_input.parse_input_event(ev);
}
}
(registering function and such eluded). They mostly segfault, apparently on the call to _input.parse_input_event(ev)
. How should I proceed in GdNative C++ ?