Godot Version
.Net 4.5.1
Question
Hello, I am pretty new to godot and gamedev, when I run my game I have some debugging to display if some Input.IsActionPressed() and they all have the value true even when all the button pressed are false until I leave the window focus (click outside of it) and come back to it, why is that?
Output: Actions - left:True, right:True, up:True, down:True
Keys - Left:False, Right:False, Up:False, Down:False, A:False, D:False, W:False, S:False
Input vector: (0, 0)
Until i click outside the window which then works correctly
Actions - left:False, right:False, up:False, down:False
Keys - Left:False, Right:False, Up:False, Down:False, A:False, D:False, W:False, S:False
The keys booleans always reflect the ones i am pressing, the actions all start being true until I focus another window and refocus the game one, then they correctly reflect the actions being triggered
using Godot;
using System;
public partial class Player : CharacterBody3D
{
[Export]
public int Speed { get; set; } = 400;
public override void _Ready()
{
}
public void GetInput()
{
var inputVec = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down");
GD.Print($"Input vector: {inputVec}");
Velocity = new Vector3(inputVec.X, 0f, inputVec.Y);
}
public override void _Process(double delta)
{
GD.Print($"Actions - left:{Input.IsActionPressed("ui_left")}, right:{Input.IsActionPressed("ui_right")}, up:{Input.IsActionPressed("ui_up")}, down:{Input.IsActionPressed("ui_down")} ");
GD.Print($"Keys - Left:{Input.IsKeyPressed(Key.Left)}, Right:{Input.IsKeyPressed(Key.Right)}, Up:{Input.IsKeyPressed(Key.Up)}, Down:{Input.IsKeyPressed(Key.Down)}, A:{Input.IsKeyPressed(Key.A)}, D:{Input.IsKeyPressed(Key.D)}, W:{Input.IsKeyPressed(Key.W)}, S:{Input.IsKeyPressed(Key.S)}");
GetInput();
MoveAndSlide();
}
}