#Ignore project settings input map

5 messages · Page 1 of 1 (latest)

ivory mantle
#

Is it possible to temporarily ignore certain keys that are bound in the project settings input map?

Basically i want to add functionality to this InputEventKey but i already have the 1 key bound and being used in a different script. So i want to temporarily ignore the input map settings while a certain bool is true or something like that.. is it possible?

    if event is InputEventKey:
        if event.pressed and event.keycode == KEY_1:
            print("functionality")
civic oxide
civic oxide
# ivory mantle restructuring it how?

Ideally you want to decouple your input code and your objects that receive input commands. So what you do is make sure your entity has a well defined interface like move(direction), attack(), use_item(item), run(), etc. Then you make a "PlayerController" node that receives all user input. That controller then takes user inputs, and then calls the appropriate methods on the entity. This is great for a ton of reasons. You can disable all user input from one place, all your input code is organized in one place, you can switch control between the main character and any other entity with little effort, and input conflicts from multiple objects are easer to handle. In your case, it sounds like you could add a finite state machine to the PlayerController where it's either sending commands to the player entity, or to whatever object you're trying to get working depending on what state you set it to.

vernal ibex