#alright one more thing i need help with

1 messages · Page 1 of 1 (latest)

viral current
#

i seriously don't know how to do this

#

i thought i did and i attempted to but i just completely forgot how to do it

#

all i need help on is how to make it play while i'm walking

opaque tusk
#

You could check if the direction vector is higher than zero to play your footsteps

opaque tusk
#

Yeah, using input_dir, will make you play the walk sound when a key is pressed

viral current
#

i'm not very good with coding just yet

woeful crag
viral current
#

they're 2 different audios tho

woeful crag
#

if input_dir != Vector2.ZERO :
Play ur audio

viral current
#

where do i put that

woeful crag
woeful crag
viral current
viral current
woeful crag
viral current
woeful crag
#

Input dir should be above

viral current
#

above whar,,?

woeful crag
#

var hello = hello <-- above
if hello: <----
print("hello")

viral current
#

ohhhh

#

ok i see

woeful crag
#

@viral current is it working

viral current
#

idek if i'm doing it right i'm really stupid

#

☹️

woeful crag
#

Copy paste ur code

woeful crag
viral current
#

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 😔

woeful crag
#

Very very wrong

viral current
#

so what do i do to make it right,,?

woeful crag
#

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

delicate spear
woeful crag
#

if is_on_floor() and is_moving:
$AudioStreamPlayer.play()
Else:
$AudioStreamPlayer.stop()

viral current
viral current
#

oh that worked

woeful crag
#

I know

#

You're Welcome

viral current
woeful crag
#

You need to indent or unindent the if statement

#

Like press tabulation or remove one tabulation

viral current
#

i did but then it says "Expected statement, found 'else' instead"

woeful crag
#

sorry i can't help you with that

#

Im not enough smart to explain perfectly explain it

viral current
woeful crag
#

Same tabulation If
Same tabulation Elif
Same tabulation Else

Or :
Same tabulation If
Same tabulation Else

viral current
pallid snow
#

show your code

viral current
#

oh wait nvm i got it

#

wait nvm frick

#

i've been trying to get this to work for like 4-3 hours

compact verge
#

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()
viral current
#

it doesn't work without it

compact verge
#

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

pallid snow
#

put var is_moving: bool on very top of the script after extends and then delete var from the physics process function

pallid snow
woeful crag
#

nop...

woeful crag
# viral current

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

delicate spear
viral current
delicate spear
#

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

spice star
#

If you're using an AnimationPlayer you can add keyframes that play the audio precisely when the foot touches the ground

pallid snow
woeful crag
#

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

pallid snow
#

but you can learn when someone corrects you, thats how i learned

woeful crag
#

So you expect everyone to learn from other people everytime ?

pallid snow
#

why? everyone can learn their own way

woeful crag
#

exactly, and thats not what he's doing

pallid snow
#

you don't have to be rude and tell how someone should learn

woeful crag
#

he asks for a prepared dish

#

he have to build it brick by brick

pallid snow
#

he deff not gonna learn when you tell him never touch editor again

woeful crag
#

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

pallid snow
#

no you are wrong, everyone can learn their own way, there is no right or wrong way to learn things

delicate spear
spice star
#

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

quiet dove
#

@viral current learn basic python then start godot

pallid snow
quiet dove
#

also OP is struggling with gdscript so python would be easier to begin with

glacial quiver
pallid snow
woeful crag
bleak bane
quiet dove
quiet dove
glacial quiver
#

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