Dynamic Footsteps! : For Terrains and Imported Meshes (Unity3D)

Поделиться
HTML-код
  • Опубликовано: 19 июн 2021
  • Enhance the experience of your players!
    Add character sound effects that react with the environment by dynamically changing footstep sounds!
    Come Join us on the Discord!
    🎮 / discord
  • ИгрыИгры

Комментарии • 96

  • @herrmutig2656
    @herrmutig2656 3 года назад

    Thank you man!! The content quality is insane. Keep it up. Would love to see more!

  • @Pedro_Marangon
    @Pedro_Marangon 2 года назад +6

    This is honestly the best tutorial on dynamic footsteps I've seen!!

  • @alejandroparrilla5539
    @alejandroparrilla5539 2 года назад +10

    Although I got late to the party, I must say, this tutorial is unbelievably awesome! I'm not a programmer and I gave it a shot for my game. The biggest issue was that I'm not using the first person controller but the third person controller instead. I did not have access to the scripts so I had to pause frame by frame whenever you scrolled up and down :P to copy the sections that are relevant to audio. The starter assets third person controller, which is what I'm using, does not have ANY functionality for audio, whatsoever. So, I populated my player controller with what I thought made sense for my case and after a few bumps on the road I got it to work. The difference with third person controller is that instead of calling the functions from within the script by using the player's movement, speed, etc., the calls are made by adding events to the animations (in the character's animator) at the precise moment when the feet touch the ground or take off when walking, running or jumping and assigning to them the functions that are available from the script. I might venture into adding a separate List for "Running" footsteps. Overkill??
    Thank you so much for sharing your knowledge and congrats on your channel. We need more videos! Cheers.

  • @HadiLePanda
    @HadiLePanda 3 года назад +3

    One of the most amazing tutorials I've seen out there, it's very useful and self contained.
    Thanks a lot for sharing, I'd love to see more of your kind of content !

    • @NattyGameDev
      @NattyGameDev  3 года назад +1

      Thank you so much for your kind feedback!! I'm really happy you found it useful! :) I'll definitely be uploading more content over the coming months!

  • @andrewalexart
    @andrewalexart 5 месяцев назад

    Thank you for this tutorial! Didn't get the part about terrain checker algorithm, but I just followed along and everything works like a charm!
    Keep it up!

  • @sae-institute
    @sae-institute 2 года назад +5

    Great tutorial, thanks for this. I noticed in the scripts that are linked in the description that the raycast distance in the FootstepSwapper script is set to 0. In case others are using that and it's not working, just a matter of changing the raycast distance to 3f, like so: if (Physics.Raycast(transform.position, Vector3.down, out hit, 3f))
    Cheers!

  • @GreenGnoblin
    @GreenGnoblin 3 года назад

    Very nice video! It is really helpful. Keep up the good work.

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      Thank you very much :) I really appreciate the kind feedback!

  • @gmangman123
    @gmangman123 5 месяцев назад

    Impressive! Thank you master.

  • @liondev5651
    @liondev5651 8 месяцев назад

    this was a good one!

  • @tanhvi3679
    @tanhvi3679 Год назад

    Thank you a lot! ^^ you awesome

  • @seneda6145
    @seneda6145 2 года назад

    Goated fr!!!

  • @skollee8113
    @skollee8113 3 года назад

    This is an awesome tutorial! The best one out there yet I would say.

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      That is awesome to hear! I was super excited to work on this one spent quite a bit of time making the system as easy to understand and expand upon :). Thank you so much!

    • @skollee8113
      @skollee8113 3 года назад +1

      @@NattyGameDev If I have any problems when trying to implement it soon. I might have questions XD

  • @Vav97
    @Vav97 9 месяцев назад

    Great tutorial!

  • @softwet525
    @softwet525 3 года назад +10

    Why does this have so little views? It's a good, easily understandable tutorial

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      Thank you very much! I really appreciate your feedback :D

  • @rothhomemade
    @rothhomemade 4 месяца назад

    I really hope you are OK. Wish u the best.

  • @BenGodot
    @BenGodot 2 года назад +1

    what fps controller is that? also loving your series, could you add quick turn, vault (up ledges), and lean left and right when you hold a and d for example?

  • @Valhalla-Gaming
    @Valhalla-Gaming Год назад

    I followed the tutorial, but if I paint a gravel layer on the sand layer, the sound does not play when I step on the gravel or i mean it plays still sand footsteps, but on the sand layer but in a different position it plays gravel footsteps. It's like it doesn't put the layer where I paint.

  • @FERZiNANDoS
    @FERZiNANDoS 2 года назад

    Hi! Thanks for the video, but I don't hear a sound. Sound outputs are configured. I don't see the sounds changing when switching to another texture.

  • @dtalmood
    @dtalmood 8 месяцев назад

    at 12:00 in the video when you create the FirstPersonController fpc; I dont have this in my own project and i was wondering what this is supposed to be representing?

  • @FERZiNANDoS
    @FERZiNANDoS 2 года назад

    Hi! Thanks for the great video. I'm new to Unity. Can you please tell me how can I change your script to use it with Wwise and not with the Unity sound system? Thanks!

  • @viceversa6293
    @viceversa6293 2 года назад +1

    Ты лучший! 👍

  • @bedi5604
    @bedi5604 Год назад

    Can somebody help me? Unity has been changed the Standard Assets to Starter Assets, which have the new FPS Controller, much more complicated, and I cant work with it. Is there any possible way to get the old, which I can work with?

  • @babaukos
    @babaukos 4 месяца назад

    Could you post the code for the step sounds, at least in text form?

  • @manusiaberuntung891
    @manusiaberuntung891 Год назад +1

    There is no more unity standart assets right now, so i cant follow along 😢

  • @jarrydoneill7834
    @jarrydoneill7834 2 года назад +1

    How would you implement this into a 2d top down game?

  • @gamestacheindiegamedevelop5796

    Hey man awesome tutorial, and its all working perfect
    However, when it comes to a player being out of bounds, im struggling to figure out how to prevent the following error:
    Texture rectangle is out of bounds (512 + 1 > 512)
    UnityEngine.TerrainData:GetAlphamaps (int,int,int,int)
    basically the player is outside of the terrain (as a test) and I guess it throws an error because it exceeds the terrains alphamaps
    how would i get around this?
    thanks!!

  • @rainbowslime6957
    @rainbowslime6957 6 месяцев назад

    Hello brother, very sorry for asking so late, but coule you give me thef first person controller script you are using? I meed the view bobbing ans others please🙏❤️

  • @KJPiGames
    @KJPiGames Год назад

    What is the name of the sound pack that you used in the project? Is it paid or did you collect them yourself? Could you throw it off for review, please?

  • @juliaalder2007
    @juliaalder2007 2 года назад +1

    Awsome! Could you make a skill system? So if the player gains XP and levels up he can choose if he wants to lern a new skill or get better at an existing one. This would be amazing! :)

    • @NattyGameDev
      @NattyGameDev  2 года назад +2

      thanks for your comment! I am currently working on the next video in the series which covers this exact topic.. Im still in the prototyping phase so I don't have an expected date yet, but I'm working on making it a strong and self contained foundation to build your own system upon ! :)

    • @juliaalder2007
      @juliaalder2007 2 года назад

      @@NattyGameDev Oh, man. Love to read this. I'm so lost. Take your time and I'm so excited to see it! Thanks. :)

  • @foxxo_company
    @foxxo_company Год назад +4

    Some of the script search my other comment to get more of these:
    TerrainChecker
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class TerrainChecker
    {
    private float[] GetTextureMix(Vector3 playerPos, Terrain t)
    {
    Vector3 tPos = t.transform.position;
    TerrainData tData = t.terrainData;
    // players X and Z positions relative to terrain.
    int mapX = Mathf.RoundToInt((playerPos.x - tPos.x) / tData.size.x * tData.alphamapWidth);
    int mapZ = Mathf.RoundToInt((playerPos.z - tPos.z) / tData.size.z * tData.alphamapHeight);
    float[,,] splatMapData = tData.GetAlphamaps(mapX, mapZ, 1, 1);
    float[] cellmix = new float[splatMapData.GetUpperBound(2) + 1];
    for(int i = 0; i < cellmix.Length; i++)
    {
    cellmix[i] = splatMapData[0, 0, i];
    }
    return cellmix;
    }
    public string GetLayerName(Vector3 playerPos, Terrain t)
    {
    float[] cellMix = GetTextureMix(playerPos, t);
    float strongest = 0;
    int maxIndex = 0;
    for(int i = 0; i < cellMix.Length; i++)
    {
    if(cellMix[i] > strongest)
    {
    maxIndex = i;
    strongest = cellMix[i];
    }
    }
    return t.terrainData.terrainLayers[maxIndex].name;
    }
    }
    FootstepSwapper:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityStandardAssets.Characters.FirstPerson;
    public class FootstepSwapper : MonoBehaviour
    {
    private TerrainChecker checker;
    private FirstPersonController fpc;
    private string currentLayer;
    public FootstepCollection[] terrainFootstepCollections;
    void Start()
    {
    checker = new TerrainChecker();
    fpc = GetComponent();
    }
    public void CheckLayers()
    {
    //raycast down
    RaycastHit hit;
    if (Physics.Raycast(transform.position, Vector3.down, out hit, 3))
    {
    //check if terrain exists
    if(hit.transform.GetComponent()!= null)
    {
    Terrain t = hit.transform.GetComponent();
    //if layer matches our currentLayer
    if(currentLayer != checker.GetLayerName(transform.position, t))
    {
    currentLayer = checker.GetLayerName(transform.position, t);
    //swap footsteps!
    foreach(FootstepCollection collection in terrainFootstepCollections)
    {
    if(currentLayer == collection.name)
    {
    fpc.SwapFootsteps(collection);
    }
    }
    }
    }
    }
    }
    }

  • @muhsinakhan6726
    @muhsinakhan6726 2 года назад

    Can someone provide me the audio clips he used in his video? Will be very helpful for ne

  • @raydani8748
    @raydani8748 Год назад

    How do you rename terrain layers?

  • @Tyber_gsk
    @Tyber_gsk 2 месяца назад

    Hello.
    Thank you for this great video..
    If i would like to use this metod in third person controler ..... fpc need to be change to tpc in the scripts and it should work.......................?
    regards..

  • @Swatgoezhigh
    @Swatgoezhigh 2 года назад +1

    awesome tutorial! do u have any idea why my chekcer always chose my last layer although i never used it on my terrain?

    • @Swatgoezhigh
      @Swatgoezhigh 2 года назад +1

      nvm i forgot if( cellMix[i]> strongest) ... thanks again for the nice video!

  • @vl4dixx
    @vl4dixx 2 года назад

    Hey, this is a very good tutorial, thanks.
    Do you have a tip how to implement this with the ThirdPersonController? I got it working on the jump and landing sound but I can't really get the footsteps right.
    Best regards.

    • @NattyGameDev
      @NattyGameDev  2 года назад +2

      Have a look at setting up animation events.
      Using animations events you could call a function that plays a random footstep every time your characters foot makes contact with the ground,
      Combine that with the raycast checks we do in this video and that should work :)

    • @vl4dixx
      @vl4dixx 2 года назад

      @@NattyGameDev Oh Nice it works thanks! :)

  • @TheAwesomeAlan
    @TheAwesomeAlan 2 года назад +2

    Also, I read in another comment that you'd upload the scripts - would you still consider doing that? They aren't in the description and I just can't get mine to swap the audio.
    EDIT: Super simple solution, I hadn't labeled the terrain layer and the collection the same name. Since they were different, the script wasn't starting correctly.

    • @NattyGameDev
      @NattyGameDev  2 года назад +2

      absolutely! I will do this now, I thought I had uploaded them! :O

    • @wfpnknw32
      @wfpnknw32 2 года назад

      @@NattyGameDev Hi Love the tutorial! although it's hard to focus on what you're doing because I need to type everything out instead. Do you have the scripts in files? (dont need the audio files or anything just the files are good. thanks!

  • @BmoreGaming
    @BmoreGaming 8 месяцев назад

    How performant is it to use raycasts? If there are 500+ people all using a similar script, do you think it would cause issues?

    • @nightflared
      @nightflared 7 месяцев назад +1

      You can optimize it by calculating only raycasts of footsteps that player can hear (by using footsteps sound distance)

  • @freddygarcia6688
    @freddygarcia6688 Год назад

    I have a question... If I have an imported mesh with different materials.... Is necessary separate the model with the different textures?

  • @sdp_theoldone9918
    @sdp_theoldone9918 2 года назад +1

    Love your videos man! I got one question. Are your scripts for xp and health bar free to use and if so could I use it in my game that I will put on Steam for money. Im asking cuz Im still kinda new to this turtorials if they're free to use or not so I rather ask rather that not. Keep up the great work!

    • @NattyGameDev
      @NattyGameDev  2 года назад +1

      Absolutely, You can use this in your commercial product.. all I ask is that you let me know when its out! :D ..and maybe a sub :p

    • @sdp_theoldone9918
      @sdp_theoldone9918 2 года назад

      @@NattyGameDev Thank you! I will let you know when it comes out. If I finish it that is of course. I dropped a sub :) Keep it up!
      Oh and my English isnt very good if it wasnt clear by my sentence writing xD

  • @ProdMGD
    @ProdMGD 2 года назад +1

    It switches the sound one time then never switches to anything else. Trying to find where I went wrong. What should the terrainchecker be attached to? I only see the example with one.

    • @NattyGameDev
      @NattyGameDev  2 года назад

      Sorry for the delayed reply! This one slipped past my radar. How did you go with this ?? TerrainChecker is a class that we are creating in our FootstepSwapper script. It doesn't inherit from Monobehaviour and therefore can't be attached to a Gameobject we create a new instance of the class with the line checker = new TerrainChecker();

    • @ProdMGD
      @ProdMGD 2 года назад

      @@NattyGameDev Forgot what I did but I spent the night on it and it works beautifully. I implemented this rather late into development so the error was likely on me. Anyone implementing this in a relatively new project shouldn't have much issue. Great tutorial!

    • @NattyGameDev
      @NattyGameDev  2 года назад

      @@ProdMGD Thanks so much! Really glad to hear that you got it working, All the best with your project! :D

  • @IndieSurgeGamesYT
    @IndieSurgeGamesYT 3 года назад +1

    How can you hook this upto any character and not just the unity character?

    • @NattyGameDev
      @NattyGameDev  3 года назад +1

      In order to do this you will need to write a function which incrementally plays a sound... Very similar to how the unity FPC does it.. I can provide an example of this in a few hours :) (at work right now).
      But It will also depend on how you have set up your character, eg do you have a head Bob? Do you have a character model where the footstep need to align with an animation? Thanks for the question!

  • @talha_abbas
    @talha_abbas 3 года назад +2

    Hey sir. Great Tutorial.
    Can I get a link to the game files. Can't seem to get the scripts working 😊😊😊

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      Sorry for that late reply ! Sure. I will update the description to include a link to the scripts today! Unfortunately I used a few SFX from a package so I won't be able to upload the sound files.

  • @lindal93
    @lindal93 2 года назад

    Wonderful tutorial, thank you! I have a question: How do you make the same step sound from the entire random footsteps list not repeat twice in a row? In the initial settings of the player’s controller, the steps sound one after another and it is quite natural. But how to achieve the same with one sound list?

    • @kyleclark795
      @kyleclark795 Год назад

      I know this is a bit old but off the top of my head, I'd take the line where he says 'int n = Random.Range(1, m_FootstepSounds.Count)' store that in another variable called lastSoundPlayed or something and prior to running through that method again, do a check to see if n = lastSoundPlayed and if it is, randomly choose another sound again.

  • @rickveldkamp4217
    @rickveldkamp4217 2 года назад +1

    Awesome tutorial! It doesn't seem to work for me though. I've checked everything thrice I think. Really not sure what I could've done wrong! Only thing that is different is that I've applied a material to the terrain. Any idea if that could've f*d it up? Would really love to make this work!

    • @NattyGameDev
      @NattyGameDev  2 года назад

      So do you mean under the terrain settings you have changed the material? if so what kind of material did you change it too?

    • @NattyGameDev
      @NattyGameDev  2 года назад

      I tried to change the material of the terrain in my scene.. and it removed all of the textures that I had painted on there... So yeah, that maybe the issue.. are you using HDRP?

    • @rickveldkamp4217
      @rickveldkamp4217 2 года назад

      @@NattyGameDev Yeah I changed the material in the terrain settings! I'm gonna try and remove it and just paint on a texture. See if that works! I'm using built-in. Thanks for the quick reply btw!

    • @rickveldkamp4217
      @rickveldkamp4217 2 года назад

      @@NattyGameDev I tried but failed! I also tried to add a new terrain and just paint on a texture, but that still doesn't work. I don't get any errors or warnings, it just isn't changing.

    • @NattyGameDev
      @NattyGameDev  2 года назад

      @@rickveldkamp4217 The only other thing I can think of is maybe the raycast is not long enough to reach the ground?? how tall is your character controller? :)

  • @bytoxx897
    @bytoxx897 2 года назад

    This was a great tutorial! But I wanted to ask:
    You know how to implement this on the new First Person project made with the new Input System & Cinemachine?
    I know you're using the Standard Assets, but if you have a tip on this matter, it would be very much appreciated!
    Edit: Never mind. I've got it working now. I did recreate the function ProgressStepCycle of the First Person Controller Script looking how was functioning. Now works like a charm. Thank you!

  • @foxxo_company
    @foxxo_company Год назад +1

    Scripts 2:
    FootstepCollection:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    [CreateAssetMenu(fileName = "New Footstep Collection", menuName = "Create New Footstep Collection")]
    public class FootstepCollection : ScriptableObject
    {
    public List footstepsSounds = new List();
    public AudioClip jumpSound;
    public AudioClip landSound;
    }
    The FPS Script i cant post it

  • @yonesbarghi301
    @yonesbarghi301 Месяц назад

    Please Links download script

  • @owerl1n2
    @owerl1n2 2 года назад +1

    hey there natty! could you please help me? i'm stuck at fixedupdate - my footsteps are being called a million of times, and i can't understand the problem. i've spent a lot of time searching and googling. nothing helped :c
    i'm using this fps controller: /watch?v=PKL4-8rOxMQ

    • @owerl1n2
      @owerl1n2 2 года назад +1

      lol finally worked. just needed to add step interval :\

    • @NattyGameDev
      @NattyGameDev  2 года назад +1

      Really sorry I missed this! I've been really focused on getting my next video out. Thanks for letting me know you got it working, Very glad to hear! :)

  • @shubhampatel8193
    @shubhampatel8193 2 года назад

    Where can I get the script..

    • @NattyGameDev
      @NattyGameDev  2 года назад +1

      Right here in the video! we go through it step by step :D

  • @laranlors9651
    @laranlors9651 3 года назад

    Hello, thanks for the amazing tutorial, can this be used in a scene with multiple terrains?

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      Your very welcome! Yes this should work across all terrains, because we are passing a terrain component each time we want to play a footstep :)

    • @laranlors9651
      @laranlors9651 3 года назад

      @@NattyGameDev I got in my game a custom first person controller and it seems like this is not working for it, any ideas what should i do?

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      @@laranlors9651 how are you getting your player controller to play the sound?
      You can use the process showed in the video to dynamically change the footstep audio clips, you will need setup this up in conjunction with system that plays a sound incrementally.
      Each time just before you play the sound, you will have check to see which collection of footsteps to play :)

    • @NattyGameDev
      @NattyGameDev  3 года назад +2

      @@laranlors9651 did you end up getting it working ? :)

    • @laranlors9651
      @laranlors9651 3 года назад

      @@NattyGameDev Kind of worked

  • @raelroque5595
    @raelroque5595 2 года назад

    the guy took a ready-made controller script full of lines, and added the lines of codes,
    so it's hard to understand, not everyone is a programmer this video makes me frustrate

    • @NattyGameDev
      @NattyGameDev  2 года назад +1

      You don't have to worry about all the other code in Unitys FPSController script.. just focus on the lines of code that we add into the script in this video.
      It's ok that not everyone is a programmer, and it can be difficult in the early days.
      The more you program, the easier it will get, I promise!
      Let me know where you are struggling and I will help you out :)

    • @raelroque5595
      @raelroque5595 2 года назад

      @@NattyGameDev i did my own character controller, now i just want to learn how to apply footsteps sounds, but it need to be simple, im trying to do on another code, I'll try again later

    • @VileCarney
      @VileCarney 2 года назад +4

      @@raelroque5595 its never going to be simple my guy

  • @HipsTeris
    @HipsTeris 3 года назад +1

    Hello there, do you have a discord ?

    • @NattyGameDev
      @NattyGameDev  3 года назад +1

      Hi there! I don't have a discord yet, but it is definitely something I am looking into setting up as a way to interact with the community! Thanks for asking and I will definitely let you know when I have set one up :)