I’m new to game dev and godot in general and i can’t get a timer(no talking about the node) to work. I was trying to do a jump king clone for a game jam but wasn’t able to get the charging jump to work. Can someone explain to me how to do it in C#.
One very simple way to do it without a timer node is like this:
//create a jumpTimer float somewhere
float jumpTimer
public override void _PhysicsProcess(double delta)
{
if (Input.IsActionPressed("jump"))
{
//+1 every second you hold jump (edited)
jumpTimer += delta
}
else
{
//Resets jumpTimer when not jumping
if (jumpTimer > 0.0)
jumpTimer = 0.0
}
}
Read the jumpTimer or call a jump function before setting the jumpTimer back to zero, which doesn’t have to be in the “else” part but it’s easy to understand like this. You may want to move inputs out of the physics process anyway, and you can use the ActionJustReleased for these things as well.
This is very basic though so i’d recommend just watching a bunch of videos or read up on godot’s timers
My bad, delta time already takes into account the frame rate, my initial comment was wrong. Without delta it would have been every frame jumpTimer += 1.0
in the case of delta it’s seconds.
Also i use gdscript so that’s where the error came from.