#alright one more thing i need help with
1 messages · Page 1 of 1 (latest)
i thought i did and i attempted to but i just completely forgot how to do it
i have 2 seperate audio files that have the first footstep and the second
all i need help on is how to make it play while i'm walking
You could check if the direction vector is higher than zero to play your footsteps
you mean this vector?
Yeah, using input_dir, will make you play the walk sound when a key is pressed
well since i'm not a professional coder how exactly would i do that-
i'm not very good with coding just yet
You want to play the sound on any key pressed ?
yes
they're 2 different audios tho
if input_dir != Vector2.ZERO :
Play ur audio
where do i put that

Physics process
sorry-
thank u!!
Dw
what does this mean-
Input dir should be above
above whar,,?
var hello = hello <-- above
if hello: <----
print("hello")
@viral current is it working
Copy paste ur code
Don't worry bro its completely alright
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
var input_dir = "left"
if input_dir != Vector2.ZERO :
$AudioStreamPlayer.play()
i know this is probably wrong
it looks really wrong
idk what i'm doing man 😔
Very very wrong
so what do i do to make it right,,?
func _physics_process(delta: float) -> void:
# Apply gravity
if not is_on_floor():
velocity += get_gravity() * delta
This is correct
Below this put this :
var input_dir = Input.get_vector("left", "right", "up", "down")
var is_moving : bool = input_dir != Vector2.ZERO
I made an addon for this you can try: https://github.com/COOKIE-POLICE/godot-material-footsteps
if is_on_floor() and is_moving:
$AudioStreamPlayer.play()
Else:
$AudioStreamPlayer.stop()
i might try this another time
it says
"Cannot infer the type of 'is_moving' variable because the value doesn't have a set type."
I edited my msg
Look again
oh that worked
it says
"Expected indented block after 'if' block"
Im not the problem
You need to indent or unindent the if statement
Like press tabulation or remove one tabulation
i did but then it says "Expected statement, found 'else' instead"
Please learn godot basics...
sorry i can't help you with that
Im not enough smart to explain perfectly explain it
sorry i just started-
Same tabulation If
Same tabulation Elif
Same tabulation Else
Or :
Same tabulation If
Same tabulation Else
it has the same tabulation but for some reason it still says it
show your code
oh wait nvm i got it
wait nvm frick
i've been trying to get this to work for like 4-3 hours
you have : bool at the end of the if statement you dont put a type there.
if is_on_floor() and is_moving:
$AudioStreamPlayer.play()
else:
$AudioStreamPlayer.stop()
i have bool there so "is_moving" can work
it doesn't work without it
because youre declaring is_moving in the if above.
it loses scope once that if ends.
define var is_moving: bool in the class scope
put var is_moving: bool on very top of the script after extends and then delete var from the physics process function
and then this will work
nop...
Please never touch the editor again
Go watch some videos to understand how to code
I explained you how to do and you're still failing
calm down...
Ngl acceptable response, cuz as you can see in the picture bro actually doesn’t know basic syntax 
i just started i'm not very good at stuff like this
It’s okay to not be that good when you start that said you have to know basic syntax at least which you don’t and like Taka said go watch some videos about gdscript basic syntax
If you're using an AnimationPlayer you can add keyframes that play the audio precisely when the foot touches the ground
you don't have to know that to start, i started without knowing and learned by just doing things
he defintely have to know basic syntax
very important
otherwhise you write some random shit that you don't understand and expect it to work
then ask in a discord server for help
but you can learn when someone corrects you, thats how i learned
So you expect everyone to learn from other people everytime ?
why? everyone can learn their own way
exactly, and thats not what he's doing
you don't have to be rude and tell how someone should learn
he deff not gonna learn when you tell him never touch editor again
he will def learn more sitting on his chair watching videos rather than writing some random text
tutorials are meant for that
so why not watch them
no you are wrong, everyone can learn their own way, there is no right or wrong way to learn things
So supposedly you’re supporting the method of learning called “bothering other people to help you learn basic syntax that you can learn in a few hours from a few videos.” Great to know. Like Taka said he clearly doesn’t understand the random text he is writing.
I also agree with Taka & Cookie
I am also new to Godot and I must have spent hours and hours in watching tutorials & reading the documentation. Unfortunately sometimes there's no good info on certain things, or we have a unique problem, that's why we ask on the forums, so those who have experience with that issue can help. But overall, it's better to learn basics first so you know what you're doing
@viral current learn basic python then start godot
i started godot without any programming knowledge, and learned by trying not watching tutorials
that doesnt make tutorials a bad thing
also OP is struggling with gdscript so python would be easier to begin with
and who is saying tutorials are bad? im just saying you don’t have to push a way to learn
It is often easier to transmit knowledge than to acquire it by your self
python is just as complex as GDScript. It isn't any easier to learn.
But a programming course that uses python would be useful since they will cover more general stuff than a GDScript one.
most gdscript tutorials begin with teaching stuff like nodes and gdscript's own stuff and will likely miss some of basic syntax, while python tutorials only teach syntax thats enough to move onto gdscript
not much people can learn like you did. of course people can learn in any way they want but i find this the easiest way
imo, setting up the ide(vscode or whatever) + linting is most of the pita for python. not to mention the cryptic bloated error outputs and working with "terminal". ofc it doesnt hurt to learn it, but the ecosystem is different and that might be too overwhelming or even boring. with godot its all there. my 2 cents