How do I use delta time to measure the time since I pressed a button and held it?

I want to have smooth acceleration on a character. By using the formula 1/2 * a * t² where a is the acceleration constant (lets say e.g. 2) and t the delta time since the button press.

How is that possible?

Thanks in advance

Isn’t this the same as you asked before?

Technically yeah, but I got no real answers.

The way I would do is on the Button’s pressedstart event (https://developer.playcanvas.com/en/api/pc.ButtonComponent.html#event:pressedstart), set a boolean to true and in the update function, if that boolean is true, add the deltatime to another variable (eg timeHeld).

When the pressed Button’s pressedend event, set that boolean to false.

Real answers require real questions.