Skip to content

Instantly share code, notes, and snippets.

@Einlander
Last active February 3, 2021 22:54
Show Gist options
  • Save Einlander/05be4f0d77e0440ad2ee906be00ddd17 to your computer and use it in GitHub Desktop.
Save Einlander/05be4f0d77e0440ad2ee906be00ddd17 to your computer and use it in GitHub Desktop.
Generates some simple keymaps
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _enter_tree():
push_warning("WARNING Generating Key Maps: Be sure to use the Input Map in the release")
print("WARNING Generating Key Maps: Be sure to use the Input Map in the release")
func _ready():
var ev = InputEventKey.new()
ev.scancode = KEY_SPACE
InputMap.add_action("player_jump")
InputMap.action_add_event("player_jump", ev)
var ev1 = InputEventKey.new()
ev1.scancode = KEY_W
InputMap.add_action("player_forward")
InputMap.action_add_event("player_forward", ev1)
var ev2 = InputEventKey.new()
ev2.scancode = KEY_S
InputMap.add_action("player_backward")
InputMap.action_add_event("player_backward", ev2)
var ev3 = InputEventKey.new()
ev3.scancode = KEY_A
InputMap.add_action("player_left")
InputMap.action_add_event("player_left", ev3)
var ev4 = InputEventKey.new()
ev4.scancode = KEY_D
InputMap.add_action("player_right")
InputMap.action_add_event("player_right", ev4)
var ev5 = InputEventKey.new()
ev5.scancode = KEY_SHIFT
InputMap.add_action("player_run")
InputMap.action_add_event("player_run", ev5)
var ev6 = InputEventKey.new()
ev6.scancode = KEY_CONTROL
InputMap.add_action("player_crouch")
InputMap.action_add_event("player_crouch", ev6)
var ev7 = InputEventKey.new()
ev7.scancode = KEY_E
InputMap.add_action("player_use")
InputMap.action_add_event("player_use", ev7)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment