Home Game Development How to make use of key bindings in Godot from C++ extension code?

How to make use of key bindings in Godot from C++ extension code?

0
How to make use of key bindings in Godot from C++ extension code?

[ad_1]

I’ve created a easy C++ “recreation” in godot. Lacking any good documentation, I primarily based my work off examples on the web, and for enter I’ve this:

    const Input* i = Input::get_singleton();

    double delta_v = 0;
    if (i->is_action_pressed("ui_up"))
        delta_v += acceleration * delta;
    if (i->is_action_pressed("ui_down"))
        delta_v -= acceleration * delta;
    if (i->is_action_pressed("ui_left"))
        angular_velocity -= angular_acceleration * delta;
    if (i->is_action_pressed("ui_right"))
        angular_velocity += angular_acceleration * delta;

Based on that, I needed so as to add a brand new motion triggered by house. So I attempted this:

    const Input* i = Input::get_singleton();
    if (i->is_action_pressed("game_shoot"))
    {
        
    }

I then added this motion within the mission key mapping:

enter image description here

But I get an error:

The InputMap motion "game_shoot" does not exist.

Curiously, it really works from a script like this:

func _input(occasion):
    if occasion.is_action_pressed("game_shoot"):
        print("game_shoot occurred!")

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here