how to use Unity's animation events ✨sync effects with footsteps

Ғылым және технология

This is another little Unity engine tutorial about how to use animation events! They can be used for all kinds of things, but in this video I show how to use animation events to sync up an effect (a particle effect or a sound, maybe) with a character's footsteps. You can use this to create little puffs of dust, or a stepping sound, or even something more advanced.
🦑 Where am I?
website: www.savallion.com
sticker shop: www.savallion.com/shop
watch on Twitch: / savallion
peep my insta: / thesavallion
Read me on Medium: / lysscreative
Learn from me on Skillshare: www.skillshare.com/r/user/aly...
☕ ko-fi.com/savallion
If you liked this, you can support me by watching more of my videos, hanging out with me on Twitch, or buying me a kofi coffee at the link above

Пікірлер: 28

  • @ivancarranza2473
    @ivancarranza24735 күн бұрын

    Wow. Great tutorial. Thanks so much!

  • @MrRevsRs
    @MrRevsRs Жыл бұрын

    Great video! My run animation and footstep sounds are now synced up perfectly

  • @MrKiraBR
    @MrKiraBR4 ай бұрын

    Great tutorial, thank you so much!

  • @rackneh
    @rackneh Жыл бұрын

    Great tutorial!

  • @sopinha-games
    @sopinha-games4 ай бұрын

    Thank you so much. That was awesome, so well explained.

  • @andreygubin2047
    @andreygubin204711 ай бұрын

    Thanks a lot, what was very helpful.

  • @HangryAnimalsGame
    @HangryAnimalsGame7 ай бұрын

    Thanks for this! you're right, there aren't many resources out there for this kind of nuanced explanation. This saved me a days worth of researching and random forums with so many a false result. Event Chat GPT fell short.. thankfully :P Liking the content!

  • @Savallion

    @Savallion

    7 ай бұрын

    You're welcome! I'm glad it helped.

  • @jhancarloscelimaldonado3793
    @jhancarloscelimaldonado37932 ай бұрын

    I really where needing this video, thanks you

  • @Savallion

    @Savallion

    2 ай бұрын

    Glad it was helpful!

  • @Inferim
    @Inferim10 ай бұрын

    Neat!

  • @RexSmithII
    @RexSmithII Жыл бұрын

    What is the easiest way if I’m bringing in animation to a model that the dialogue is already sync up? Is there a easy way for just adding a sound to the animation without events?

  • @Savallion

    @Savallion

    Жыл бұрын

    I think your instinct is right - I wouldn't use animation events for this. I personally haven't done dialogue synced with animations (yet), but I think I would probably just have the animation on a Trigger in the Animator. Then, I would have some code that sets the animator Trigger & plays the dialogue sound at the same time. Since you'll likely need some kind of system to show the dialogue on screen anyway, there should be central place where you can fire off these events all together (and by this I mean regular events, not animation events). This would also allow you to trigger different animations based on the dialogue. Whatever system you're using to load the dialogue text & sound could also have an animation trigger name attached to it. I hope that helps!

  • @megupets
    @megupets Жыл бұрын

    Awesome tutorial. Seems very simple. If I wanted to assign different sounds for footsteps, do example. Walk on grass sound Walk on dirt sound Walk on wood sound Is it a similar process?

  • @Savallion

    @Savallion

    Жыл бұрын

    It is a similar process, but you'll need another code piece to tell your animation event *which* sound it should play based on the position. I have seen some people use a texture to store the material of the terrain at every position, and look up the material from that texture. I have not done it myself but that is probably how I would try it first if I was going to add this feature. However you handle the terrain material lookup, in your animation event you will want to get the position of either the foot bone GameObject or the player transform itself, use that position with the code I mentioned to figure out which material you're stepping on, and then play the correct sound. You can save references to the foot bone or player transform the same way as we are saving references to the particle systems -- as a variable through the Inspector.

  • @allndall7126

    @allndall7126

    Жыл бұрын

    Use layer

  • @dattran1630
    @dattran16304 ай бұрын

    error CS1061: 'ParticleSystem' does not contain a definition for 'play' and no accessible extension method 'play' accepting a first argument of type 'ParticleSystem' could be found (are you missing a using directive or an assembly reference?) This is the problem I have, please tell me what the error is and how to fix it , THANK U

  • @Savallion

    @Savallion

    4 ай бұрын

    If you are ever having a problem with one of Unity's components / packages / libraries / etc. you should refer to the documentation for it to find the problem. Here is the ParticleSystem documentation: docs.unity3d.com/ScriptReference/ParticleSystem.html From the brief error message you've posted here, I would guess the problem is using a lowercase "play" instead of "Play" but in the end I cannot debug your code for you, you will have to learn how to do it :)

  • @fl641
    @fl641 Жыл бұрын

    Cant get the EVENTS in the inspector. I do not know why, I do not know what I am missing. It sais "NO ANIMATION DATA AVAILABLE IN THIS MODEL".. but i have several animations working fine in the game. Can someone help me?

  • @fl641

    @fl641

    Жыл бұрын

    I have imported all my models from blender to unity, but I created the animations in Unity. So all animations are working on my game but i just happen not to have the "events" in animations in the inspector of the model.. Any idea about how to fix this?

  • @Savallion

    @Savallion

    Жыл бұрын

    You mentioned that you used Unity to make the animations, not Blender -- this means that you won't have animation data in the model. To add animation events to your Unity animations you will need to open that animation in the Animation window (not to be confused with the Animator window, they have very similar names). From there, you won't have a separate section that says "events" but you can see just below the seeking controls there is a small button with the same little arrow flag icon that you can use to add animation events to Unity animations. This page on Unity's documentation should show you exactly where it is: docs.unity3d.com/Manual/script-AnimationWindowEvent.html

  • @fl641

    @fl641

    Жыл бұрын

    @@Savallion thank you so much for your help! I really appreciate. And thank you so much for this great video :)

  • @Bond007in
    @Bond007in9 ай бұрын

    10:30 start

  • @MikeGlaxo
    @MikeGlaxo Жыл бұрын

    Nice one, top clarity. Please add more energy. Thx and bye

  • @ferasalfarsi897
    @ferasalfarsi8977 ай бұрын

    Please, zoom in. the script is very small. It is hard to see and read.

  • @Savallion

    @Savallion

    7 ай бұрын

    Apologies! I do try to increase text size on code for videos, but I must have forgotten on this one. If it helps, the code is quite simple. First, within the component I have two public variables for the left foot ParticleSystem and the right foot ParticleSystem (these are assigned in the inspector). Within a void function called FootStepEvent which takes in an integer "whichFoot", we have an if statement. If whichFoot is 0, we call .Play() on the left foot particle system, and else we call .Play() on the right foot particle system. That's all it's doing!

  • @ferasalfarsi897

    @ferasalfarsi897

    7 ай бұрын

    Thank you so much for you assist @@Savallion It works!!

  • @DaveSucker
    @DaveSucker10 күн бұрын

    hmm now that was helpful

Келесі