I feel embarrassed asking this but I’ve Googled approaches besides what I’ve tried and I feel like I’m missing something simple here.
How do you test keyboard input in the _process() method when using Input.get_vector() or Input.get_axis() or similar?
As an example below…
direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
velocity = direction * max_speed
position += velocity * delta
If I put a breakpoint on the direction= line, it won’t take input from the app at that point yet. If I step into/over, the app doesn’t wait for keyboard input and once at the velocity= line, I always have a direction Vector2 with a value of (0,0).
How do you have the app wait for keyboard input and actually capture it while debugging? I feel I’m missing something so simple or basic.
If I understand you correctly, you want to set a breakpoint when the input vector is not zero.
As far as I know, the editor does not currently support conditional breakpoints via the UI. However, you can use the breakpoint keyword with a condition:
if direction != Vector2.ZERO:
breakpoint
Depending on what exactly you want to inspect, it might actually be better to just print the input-vector. Then you get ‘real-time’ feedback.
That’s a good approach and didn’t realize you can use code to instantly cause a breakpoint - but makes sense now that I think about the need. I’m reading the documentation (it’s so good) but also doing courses through GDQuest and GameDevTv to learn and I’m sure it would have come up eventually.
I can print the vector values to the Output tab and check as they come in but it’s also hard because you get a lot of spam. If I recall correctly, I used something like await get_tree().create_timer(1.0).timeout to wait before key presses are processed so I could read the Output, but it had it’s own problems.
I’ll try your approach and it will help me with other things as I keep learning.