Input of mouse cancels keyboard input only the first time a mouse button is clicked[SOLVED]

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

I’m new to godot and I’m making a simple platformer game. My game uses the wasd keys as input: a-move left; d-move left; w-jump. While designing and testing the character’s movement, I noticed that if I clicked any of the mouse buttons while jumping (pressing the w key and s or d key at the same time) the character stopped moving horizontally. It seems that the game stops detecting the a/d key input of the keyboard after clicking a mouse button, even though the a/d key is still physically pressed. The weird thing is that this only happens the first time I click any of the mouse button, but after that it works just fine (After this first time, I can press the mouse buttons while jumping and the character doesn’t stop)

This is the code for my character:

extends KinematicBody2D

var velocity = Vector2(0,0)
var jumped = false
var t = 0

func _physics_process(delta):

    velocity.x = 0

    var up = Input.is_key_pressed(KEY_W)
    var right = Input.is_key_pressed(KEY_D)
    var left = Input.is_key_pressed(KEY_A)
    if(right): print(t)

    if(up and is_on_floor() and not jumped): 
	    velocity.y -= 1150

    velocity = move_and_slide(velocity, Vector2(0, -1))

I’m using godotV3.2.2-stable in Linux Mint

I cannot reproduce your issue (using v3.2.2-stable and Arch Linux) and don’t see anything wrong with the code you provided. Can you upload an example project?

njamster | 2020-07-16 18:10

Yes. The thing is I don’t know where. Where do people in the godot community usually upload their sample projects?

grizwood | 2020-07-24 01:08

I found out what was happening. It turns out I was attaching the wrong script. Anyways, thank you for your interest.

grizwood | 2020-07-24 01:47

Glad you were able to resolve your problem. :slight_smile:

Where do people in the godot community usually upload their sample projects?

To answer that anyways: wherever you want! Just google “file upload” and you’ll find a dozen of sites offering you that service for free (usually with tacked on constraints like size-limits and an expiration date) - as long as you can post a link to your upload here that everyone is free to use without requiring an account there, it will work fine. :slight_smile:

njamster | 2020-07-25 11:45