im a beginner in every aspect of game development , im trying to code in a 2d playable character but for some reason it says "Nonexistent function" and im not sure where the nonexistent function is , to me it looks alright and there is no nonexistent function but thats probably because im still a beginner, i would like some help tho on how i can fix this. (Godot 4.4.1.stable)
#this question has probably been asked a million times but i really need help here.
1 messages · Page 1 of 1 (latest)
The variable you're getting in the _process() function is a float, so a type of number
You can't say 5.is_action_pressed(), as numbers don't have that kind of function associated with them
If you want to query input, you can write Input.is_action_pressed() instead. Input is a global class that you can query pretty much from anywhere
The code you probably copied from was probably something like this:
func _input(event):
if event.is_action_pressed("something"):
do_something()
The _input() function gets called whenever the game received input, and the variable contains the InputEvent associated with the input that just happened
The names of variables don't signify much; you can call any variable pretty much anything.
...but it is a good idea to call variables something sensible so your code is easier to read ^^
i got the code from godot docs
seconding neropatti
_process and _input are what we call virtual functions; if you have a _process function taking one argument in your node's script, godot will call it at certain points. in _process's case, every frame.
_process's argument isn't the same as _input's, though. for _process, the argument contains delta, a number that indicates the time passed since next frame
all that to say, _input and _process are not interchangeable function names
So in order to make it work i change process to input?
likely
but you should think about what these functions do and what you're actually trying to do
I know , im just trying to learn the basics