Let's Build the RPG! - 18 - River Sound Audio Along a Spline - Unreal Engine 5 Blueprint Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2024

ความคิดเห็น • 45

  • @NumenBrothers
    @NumenBrothers  ปีที่แล้ว +4

    If I were to do this episode again, I would have a separate and independent spline audio actor that is overlayed on top of the river (matching the shape), but that way if UE5 water is upgraded and breaks stuff, it wouldn't break the river audio. If you know how to make a Spline actor, that is what I would recommend for this episode, rather than converting the UE5 river actor into a blueprint.

    • @adsCrazyDiamond
      @adsCrazyDiamond ปีที่แล้ว +5

      I ended up reading this comment before doing this section and this is what I came up with... I made an Actor blueprint and added a WaterSpline to it. This allows me to add spline points to match and follow the UE5 river actor in my level when I drop in the blueprint. ... I then have the construction script filling in four array variables. One for collision spheres, audio components, a play sounds boolean array, and a spline intensity float array.
      I have the constructor add a collision sphere and audio component at each spline in the water spline of my blueprint. I store these in my respective array variables.
      I enter false values into all the play sound boolean array elements and I resize the spline intensity float array to the total number of splines in the water spline of my blueprint (this array I set to be instance editable so that I can manually set the volume and pitch intensity at each spline point in the blueprint details panel).
      Once the constructor is done I have four arrays filled with collision spheres, audio components, booleans, and intensity settings for each spline point I have create on this blueprint.
      (on a side note make sure and set all audio components auto activate to false or your sound will always be playing you just won't notice it because of attenuation, BTW: this was overlooked a few episodes back and those bird tweeting sounds are always playing regardless of the players location in the world... just attenuation keeps them from being heard, testable with a print string and an isPlaying test off the audio component on those blueprints)
      With the constructor done I did have to use Event Ticks to make this blueprint work. However, you can set the tick time to be every .5 seconds (or whatever you'd like) instead of every frame so it really doesn't affect performance in any way. This is done in the blueprint details panel under Actor Tick (click on Class Defaults or select the root component in the components list).
      I used a for each loop to check each collision sphere in my array of collision spheres with a 'get overlapping actors' and another for each loop to test each overlapping actor by 'cast_to_bp_thirdperson' if it hit a third person actor I set the boolean in my boolean array (at the array index of the currently tested sphere) to true.
      And off the 'Completed' pin of my for each loop that tests the collision sphere array I run a function which uses more for each loops to test the boolean array for true values and play the sound at those audio components from my audio components array (at the corresponding array index... BTW the boolean array, audio array, and sphere array all have the same amount of elements and the indexes all match the correct element for one another).
      There's a few things that need to be done here for proper playing and stopping of the sounds. Its a matter of using branches to test if an audio component is already playing the sound and if it is don't do anything if its not play the sound. Also if the boolean array value comes back false make sure to send the audio component a 'stop' playing. And make sure to set all the boolean array elements back to false at the end of each tick.
      It sounds complex but its actually fairly simple once its all set up. And the beauty is you can set the intensity at each spline point to control pitch and volume. And you can create spline points to have a sphere at each point you want along your river and the blueprint constructor will create and manage all the collision sphere, audio components for you. Plus like your comment says this blueprint is completely independent from the UE 5 water system. Its like its own little audio spline.
      Anyway, it was a great exercise and I have to thank you for suggesting it without showing how its done. It was a lot of fun to sort out and create this thing.

    • @brahimnz_
      @brahimnz_ 5 หลายเดือนก่อน

      @@adsCrazyDiamond Thank you

    • @larouguexcs2553
      @larouguexcs2553 3 หลายเดือนก่อน

      Can you please make a video showing how to 1. swim in this blueprint successfully, and 2. apply this to other river systems??

  • @AlvaroALorite
    @AlvaroALorite 11 หลายเดือนก่อน +5

    There is (IMO) a better way. Using "Get Closest Point On Collision" function you can get the audio source to attach to the surface of a volume (it has so have simple collisions though), rather than a spline. And it's not that much more computational intensive! You could spawn boxes following the spline and use them as collisions. This, from an audio point of view, is better, since the source of the audio is over an area, and not just over a point 😊

  • @Manim8
    @Manim8 ปีที่แล้ว +6

    Just a tip... You don't need to keep clicking 'Expose on spawn' for these variables. Expose on Spawn is for when you spawn something into the world at runtime. The variable will be exposed on the Spawn Actor of Class node for you to set there (you might need to right click the node and select 'refresh node' for it to show).
    For setting variables in the editor before Begin Play, you only need to select 'Instance Editable'.

  • @Dieselbird
    @Dieselbird 2 ปีที่แล้ว +3

    Really great tutorial man thank you! I messed up the attenuation settings and spent an hour figuring out why I had no sound. To anyone else having no sound play on trigger, make sure you set attenuation Inner Radius to 200 and Falloff to 2800 or something similar!

  • @jommjustonemoreminute6977
    @jommjustonemoreminute6977 3 หลายเดือนก่อน +1

    Maybe it wasn't the case when this video was made but yes, you can get the velocity, depth, or audio intensity at a spline point, using 'get float property at spline point' you just need to know the property name eg AudioIntensity or watervelocityscalar

  • @slamerlim
    @slamerlim 12 วันที่ผ่านมา

    Extremely useful stuff, thank you so much!

  • @ing_frantisek_mohykan
    @ing_frantisek_mohykan 11 หลายเดือนก่อน +1

    big respect for taking attention to sound detail. Developers overlook the importance of sound design

  • @estranhokonsta
    @estranhokonsta ปีที่แล้ว +2

    Thanks for the video. The whole series is great.
    Disclaimer. I don't know unreal.
    The following are just random uninformed ideas. I have no idea if this makes any sense for unreal.
    For the positioning sound problem at 8:20, one could try different ideas:
    Use Spline Meshes, hide them and use their collision to detect the overlap?
    Or create a mesh in the editor that conform to the river?
    Maybe use the unreal modelling tools? Use a cone and deform it with a lattice?
    Another alternative would be to try to use code (or Blueprints?) to generate the collision given the river spline. I have no idea what that would entails...
    As for the event tick situation at 20:21, one could just put manually different audio sources along the river. Note that this would be a tiresome solution if the river is very long...
    Or if the earlier spline trick worked then one advantage is that one could spawn (in the constructor) different audio sources at the spline points of the river.
    If not enough audio sources, then one can just add more spline points or create interpolated points from the existing ones?
    For the water velocity problem at 24:30, it seems there is a "get water data at point" that gives the velocity. As seen in this video from the unreal channel th-cam.com/video/7y-ITjcttW8/w-d-xo.html
    Of course that wouldn't be really a problem if the audio sources are put manually. One can change the sound and maybe give it some clamped random transformations.
    Another though about the sound when the water velocity is different. At the beginning you used 2 different sounds and mixed them together. Their pitch are very different. One looks like it is from water running more freely than the other.
    Why not change the mixing proportion depending on the velocity of the water instead of changing the overall sound pitch?

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว +2

      It's a brilliant idea- I think the water velocity isn't exposed to blueprints (I could be wrong), so that's the limiting factor- would have to do it in C++. But if it's exposed to blueprints, that seems to be a great solution, I completely agree

    • @estranhokonsta
      @estranhokonsta ปีที่แล้ว

      ​@@NumenBrothers Thanks for the reply.
      By the way, i mentioned generating the audio sources in the constructor. I think i remember seeing somewhere (i don't know where) that it wasn't a good idea to generate new objects in the blueprint constructor because of poor performance in unreal.
      Is that a fact? And if so, is there some way to generate them only in the editor, and then somewhat "baking" them to avoid influencing the performance?

  • @markbay9275
    @markbay9275 ปีที่แล้ว +1

    Loving these tutorials!

  • @jaroslavkalivoda3496
    @jaroslavkalivoda3496 2 ปีที่แล้ว +4

    Couldnt we add more capsule collisions ? the number would be float just to match number of splines, and start possition would be ending possition of previous one and aiming would be same as this.Maybe its dumb but it seems to be possible(from programming point of view at least). It would be more elegant for twisty mountain streams.

    • @NumenBrothers
      @NumenBrothers  2 ปีที่แล้ว +1

      Absolutely. I think if I were building a much longer river (thousands and thousands of units long, for instance), that's exactly what we should do in that case. But in the case of that specific level, the fact that there's only 4 rivers, pretty small space, not particularly twisty rivers, etc., I kept it simple. Also for the demonstration I wanted to keep it as a simple as possible. But I completely agree if I were making longer rivers (and I will be once I start on a main level) that's exactly how I will do it.

    • @OpinionatedHuman
      @OpinionatedHuman ปีที่แล้ว +1

      @@NumenBrothers Because of my almost 90 degree bending river, I basically copied the blueprint for calculating the capsule and changed the original part to end at the spline midpoint and made that the startpoint for a second capsule to the end point.
      To get the midpoint of the spline I simply divided the "get number of spline points" by 2 because I knew in my case I would get a round number, but what would happen if the result was an uneven number? Is there an easy way to make sure it's always a round number, example: 14 splines would get 7 but 13 splines would get 6,5 (how to prevent 6,5 spline number as that would never exist?)
      Sorry for the strange and probably unclear explanation, English is not my first language. Love your tutorial series, learning so much!

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว +1

      @@OpinionatedHuman hi, yes, there is, you can use a concatenate node from the float, or do a float -> integer node to turn it into an integer (which will do the same thing as concatenate). Hope that helps! Feel free to join the Discord if you're still running into trouble.

    • @OpinionatedHuman
      @OpinionatedHuman ปีที่แล้ว

      @@NumenBrothers Thank you for the reply, joined your Discord as well.

  • @renardsound
    @renardsound 11 หลายเดือนก่อน

    Thanks a lot for making that video ! super useful !

  • @kingslayer4080
    @kingslayer4080 ปีที่แล้ว

    For the challenge I found function "Get Location at Distance Along Spline". That should do the trick.

  • @PredatoR-rp9rk
    @PredatoR-rp9rk ปีที่แล้ว

    Such an amazing tutorial. I'm making a vehicle scene where I can drive my mountain truck through a jungle, and this tutorial helped me setting up the river sound effect inside that jungle. Do you have any tutorial covering the real time fluid simulation where water can react to the truck tire and interactable foliage where the leaves moves away from the way upon driving through them ? Thanks

  • @roryobrien6655
    @roryobrien6655 ปีที่แล้ว

    As soon as I tried to optimze from the event tick it began having issues. It seems that my player was never recognized as overlapping the capsule and therefore it did not work as expected.

  • @joeanrachelmiller6529
    @joeanrachelmiller6529 ปีที่แล้ว

    For those that want crazy precision... take all this math and calculate a capsule for between each node on a for each pair kinda loop

  • @tomraitener8281
    @tomraitener8281 ปีที่แล้ว

    Nice video but adding overlap events are not the best idea(works like a event tick). Tracing is best for performance. My idea is to sphere trace based on timer ( like 1s or perhaps more) and check if there's a water body river bp and in this case spawn sound....But perhaps i m wrong!

  • @larouguexcs2553
    @larouguexcs2553 3 หลายเดือนก่อน

    You didn’t show how to apply this to multiple rivers

  • @danialnaderi7866
    @danialnaderi7866 หลายเดือนก่อน

    i used it for my whole rivers but one of them (which is the longest one) i only can hear the sound for the half of it

    • @danialnaderi7866
      @danialnaderi7866 หลายเดือนก่อน

      I enabled "Allow tick actions" for that river and now i have sound for the full lengh of my river.
      my new question is can i use this method for beach and ocean?

    • @NumenBrothers
      @NumenBrothers  หลายเดือนก่อน

      Yes you can. I recommend having a separate spline so in case there are issues changing the blueprint, you don't crash the ocean

  • @philipmangione
    @philipmangione ปีที่แล้ว

    Since you can easily get the closest point in the Spline relative to the Player's location, wouldn't it be easier to just get rid of the collider altogether and check if the distance from the Player to the closest point in the Spline < the sound's attenuation distance?

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว +1

      You could, but you would need something that would actually cause the check to occur. Otherwise every single tick you'll be checking to see if the distance from the player to the closest point in the Spline is < the sound's attenuation distance. Hope that makes sense.

  • @NikomaGrob
    @NikomaGrob 6 หลายเดือนก่อน

    So I built everything along, I have my river set up, it looked great and moved into my lake. then I fixed all this sound, the sound is also functioning as intended. BUT NOW my whole river just disappeared after I finished the steps after 22:08 and started testing like you did, I can still hear the river, I just can't see it anymore, what's wrong here?

    • @NumenBrothers
      @NumenBrothers  6 หลายเดือนก่อน

      experimental water. I would save and restart your project at each step, make sure the river is maintained

    • @frankyin8509
      @frankyin8509 3 หลายเดือนก่อน

      oh God, same here : (

    • @frankyin8509
      @frankyin8509 3 หลายเดือนก่อน

      Weird, after random Ctrl +Z undo certain steps and crashed-restarted, the mesh came to alive again, lol

    • @NikomaGrob
      @NikomaGrob 3 หลายเดือนก่อน +1

      @@frankyin8509 Yeah I figured this out, It's as Numen says, buggy shitty water from Unreal, I still use it because it looks great and you can do fun things with it, but it does bug out, to fix it you basically just have to drag your whole river (not one splinepoint) 1 unit up or down and it reloads again and shows up. I've had it a bunch of times since my comment here and it was always after changing some landscape somewhere else in my map or whenever I work with layers on my landscape nearby a river.

  • @ssvkhraamer7579
    @ssvkhraamer7579 ปีที่แล้ว

    well followed step by step , 4 TIMES , still have my river playing M in 2D , not from the river , i'm kinda lost

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว

      It is possible that something broke/changed with rivers post 5.0, which is when I recorded this. If I were to do it again, I would have a separate and independent spline audio actor that is overlayed on top of the river (matching the shape), but that way if UE5 water is upgraded and breaks stuff again, it wouldn't break the river audio. If you know how to make a Spline actor, that is what I would do.

    • @ssvkhraamer7579
      @ssvkhraamer7579 ปีที่แล้ว

      @@NumenBrothers Oh well , I will try , thanks for the tips !

  • @TolisPiperas82
    @TolisPiperas82 ปีที่แล้ว

    i did it. if we have 2 diferent rivers we must create bp and for the other river?

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว +1

      Just drag a second river actor into the world (don't need to create two BP's, just have the same BP twice in the world)

  • @buriedbones-nh9xr
    @buriedbones-nh9xr 5 หลายเดือนก่อน

    Is that your 'married to tech support' ring?

    • @NumenBrothers
      @NumenBrothers  5 หลายเดือนก่อน

      More like Hank Moody

  • @lazytv363
    @lazytv363 ปีที่แล้ว

    How do u do this with oceans one

    • @NumenBrothers
      @NumenBrothers  ปีที่แล้ว

      Have to make a spline actor to match the shape of the ocean. Will have an episode on that some point in the future.