Godot Version
4
Question
I have written a basic script for health but when I tried to edit it the next day nothing I changed would show up in the player.
I copied the script and put it in a new file as well as making new nodes.(I did replace the old ones in script) but now nothing about the script works in player.
I have no errors.
nothing is showing up in output either.
thank you.
What happens if you press F6
?
e: also note that if your label does not have any default text set, the label will be empty until you generate an input event.
pressing f6 did not change anything, the labels will not change from there default settings
is_action_pressed("my_action")
my_action
must be defined in the input map of the project settings. Did you define it?
Select Project/Project Settings/Input Map
Did you define it though?
By default the space key is defined under ui_select
not my_action
.
Put a breakpoint inside both the if statements and see if they are actually gotten to.
If it isn’t getting to the breakpoint then either it doesn’t like your input map or it isn’t even running the function.
Put a print statement as the first line in the function and see if it gets printed.
yeah its gotta be some bug or i messed something up on accident
I rewrote the code in a diff project and it work. The problem will forever be a mystery
it started not working again about a week after i just put the code in a diff project
given this scene has no other scripts or connections: there is no way either of your functions will run on their own, they are not overriding or called by anything.
put this in dumb person terms
Your functions have no reason to run.
They both use event
so I suspect you wanted to override func _input
, which is called automatically by Godot for every input, try adding this. You will see a blue arrow beside the function name _input
if done correctly
func _input(event: InputEvent) -> void:
damage(event)
restart(event)
1 Like
thank you very much, i will now continue my constant youtube tutorial grind
yes, you removed the keyword func
so you no longer declare what these functions are, instead trying to use them without telling Godot what they are.
However you are in a unique situation where you may be better off deleting lines 11 and 23 instead of following my previous code sample.
You also set a breakpoing on line 19 (the red dot), which I don’t think was intentional and will cause the program to stop with the error “breakpoint” which is good for in-depth debugging. Click the red dot to remove your breakpoint.
1 Like