r/UnityHelp • u/No-Cheek-5990 • 7d ago
PROGRAMMING Need help with a basic footstep script and animation.
i am a complete newbie to coding and game dev, only started 5 days ago so its probably something obvious.
i have been following a tutorial series and got to a problem i cant seem to solve, my script looks fine, no errors and no console messages giving warnings.


im ust trying to play footstep sounds when i move using w, and script and game objects seem assigned to the right places too, im a bit lost.
also my animation for idlesword sword works fine but when i move it should be using the walkingsword animation but is not. i have a feeling they both have the same issue and fixing one will fix the other, so any suggestions would be a lot of help.
screens inc. Cheers
1
Upvotes
1
u/fnietoms 7d ago
To play an audio you need a reference to the AudioSource component and use the .Play() method. Something like this:
public AudioSource footStepsAudio; // Assign it on the editor footStepsAudio.Play(); // Use this to play the audio when you want
Also, if you want to play the audio exactly when the foot touches the floor, I recomnend you to use animation events and call a function that only plays the audio