Godot Version
v4.2.2.stable.mono.official [15073afe3]
Question
Hi,
I’m trying to figure out how to trigger an action from an input only once when pressing a (keyboard-) key.
The problem arises from me making my camera follow the player and then wanting to toggle that on and off. It all works until i press the button just a couple miliseconds too long and it retriggers the toggle function over and over again.
Here is my code for that for refference:
public override void _Process(double delta)
{
//…
// Toggles the locked camera input
if (Input.IsActionPressed("camera_lock_toggle"))
{
c_locked = !c_locked;
}
if (c_locked)
{
Position = GetNode<CharacterBody3D>("../Player").Position;
}
}
Thanks for the help