How to call functions or print function return values during debugging

Godot Version

4.3

Question

I’m sorry my previous description seemed too vague. For example, if I run to a breakpoint and then I want to call the get_temp_num function in the graph, can or should I enter “get_temp_num()” somewhere to see the return value of the function at this time, just like in VS2022 tuning where I can view the properties and methods of the object

do you mean like

func _ready() -> void:
	var numb :int =2
	print("print is a function and numb is a value of :",numb)

If you want specific methods or code to only run during debug, then add this check

if OS.is_debug_build():
    print("I am now in debug. I won't show up in the release")

You can also set breakpoints and the game will stop at those points during execution and lets you see the variable values at that time for debugging purpose.

If you have your game running, you can also inspect your Remote Tab. That way, you can see your SceneTree and alter many properties. Like manually setting the position of characters or stats or review the values of your objects + autoloads.

I don’t believe you can actually write a method to run manually while the game is running.
You would need to specify the method first and bind it to a button. For example Input Action Debug1 or something. Then write a _process() method to check for the Input. If the input is detected, call the method

I have rephrased the problem, thank you for taking another look

I have rephrased the problem and accompanied it with pictures. Thank you for taking another look

From the recent update to the topic, I can only think of binding the method to the Input of a key so you can run the method while the game is running.
i don’t think it is possible to call a method randomly inside of a breakpoint.
It completely depends on what the method is supposed to do.

For example:

  • If i want to track the position of my mouse cursor at all times, I would create a label and update its text with the mouse global position inside of a _process method
  • If i want to simply change a value of an object, I would do it straight from within the remote tab
  • if i want the code to go into the other if-branch, i would tie the condition to a debug boolean that i can control from within the remote tab
  • if i want to trigger the call of a method whenever i want while the game is running, i would add an inputaction and then process the input.


grafik

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.