cybereality
Thanks for all the help! I'm now trying this script instead:
using Godot;
using System;
public partial class sprite_2d : Sprite2D{
private int Speed = 400;
private float AngularSpeed = MathF.PI;
private float direction = 0;
private Vector2 velocity = Vector2.Zero;
public override void _Input(InputEvent @event)
{
if (@event is InputEventKey keyEvent && keyEvent.Pressed){
if (keyEvent.Keycode == Key.Left){
direction -= 1;
}
if (keyEvent.Keycode == Key.Right){
direction += 1;
}
if (keyEvent.Keycode == Key.Up){
velocity = Vector2.Up.Rotated(Rotation) * Speed;
}
}
}
public override void _Process(double delta){
Input.UseAccumulatedInput = false;
Rotation += AngularSpeed * direction * (float)delta;
direction = 0;
Position += velocity * (float)delta;
velocity = Vector2.Zero;
}
}
I'm sure I'm just not understanding how to use the _Input event - there's little documentation on it, or at least it's difficult to find - but this has it's own set of problems: only one key input is registered at a time, and when you hold down a key it moves for one frame, then pauses for a couple frames, then continues moving smoothly, like when you hold down a key in a text editor. On top of that, there's still the same input delay, small but noticeable with vsync, gone but with occasionally choppy visuals without.
But if using the Input singleton causes a delay in player input (I was told the same thing on Reddit), why have it in the first place, and encourage it's use in official tutorials and documentation?