Error: Condition ' !input_map.has(p_action) ' is true.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aaron M

I’m currently trying to convert a project from 2.1 to 3.0. It has some issues converting some of the input code. Here is the error log:

0:00:00:0320 - Condition ' !input_map.has(p_action) ' is true.
----------
Type:Error
Description: 
Time: 0:00:00:0320
C Error: Condition ' !input_map.has(p_action) ' is true.
C Source: core/input_map.cpp:138
C Function: action_erase_event

This is the line of code that causes it:

InputMap.action_add_event(actions_to_bind[load_bind_loop],loaded_key_event)

It seem to me that it’s telling me that it has an action already as if I’m adding an action. However, I’m only trying to an event to the action. Even when I use InputMap.action_erase_event before adding a new one, this error still occurs. Also I seem to be missing something, but I can’t find the remote inspector, which has been pretty useful for helping find the source of some bugs. This code worked just fine in 2.1, but it’s possible the arguments I’m feeding action_add_event might need adjustment.

Any clues? Is it a bug? Thanks for any help.

:bust_in_silhouette: Reply From: Karroffel

You are misinterpreting this error message. It says!input_map.has(p_action), note the !. It means that it doesn’t have an action like this.

You should do InputMap.add_action(actions_to_bind[load_bind_loop]) first before adding an event to that action.

:bust_in_silhouette: Reply From: Aaron M

Answering myself now that I figured it out. Do your action names contain whitespace? In this case they did. If it’s the same case for you, that is currently a bug in 3.0.2! It will be fixed in 3.0.3.

I tested this by compiling the latest version of 3.0.3 and it now works! Be sure to cherrypick these two fixes with these commands after checkout:
git cherry-pick ea94a8259624a1915fa4b92682755e28f2bb6af5
git cherry-pick da6c07698f591b3eac773770dc776bf095c3d9ef
Thank robfram for this one.