Let's Build the RPG! - 57 – Unreal Engine 5.1 FluidSim Interactive Water Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this episode we're turning our ue5 water up a notch with interactive fluid simulation [Music] hey guys and welcome to today's episode and today we're making our ue5 ocean interact with our player character and although we're doing this just for our ocean water body this episode this will work with any ue5 landscape water body so I'm talking lakes rivers and the ocean so the real question in this series is why spend all this time on interactive water especially when it's still experimental it's not like it's absolutely essential to make a game but I've said it before in this series so gaming is about making an interactive experience for the player it's making the player feel immersed in whatever game world you're making and in order to make the world feel alive like it and the player are one we need to aim for maximum interaction maximum interact ability between our player and our world in our game and as always if you want to know all the episodes that this episode was built upon like the footstep episodes and the gameplay ability episodes just check below and you'll find links to each one of them it's important to know that this episode was recorded on 5.1 and water is still experimental so everything we're doing in this episode is probably going to change in the future and hopefully get better and more than any other episode that we've done thus so far I could use your help with the content in this episode because on my own I've gotten it to that b plus level it's good enough but it's not doing everything that I would like it to do especially in regards to our Fireball and you'll see that by the end of the episode so if you have ideas to make this better by all means please post in the comments below so here are the key components for this episode everything revolves around the fluid Sim component actor as well as our Dynamic actors and other actors that we can use to interact with the fluid Sim actor that actually makes our water ripple so let's get to it alright just a few housekeeping things before we really get into it so make sure you got your water plugin enabled if you've already got your landscape water then you should be all set there it this water experimental under plugins and then the other thing so under the content drawer under settings in the top right corner here just make sure you have show engine content and show plug-in content here both checked and that's going to allow us to see the water content in our folder structure over here so the first thing let's get a basic fluid simulation up and running in our world and this may be obvious but you're going to need a ue5 water body like a lake a river and ocean in order to get this working so feel free to check out two episodes ago we do a complete ocean tutorial so let's get started so let's go under our content drawer and under engine navigate over to plugins and we gotta look for water content it's pretty far down the list water content here fluid simulation and then over to Blueprints and you should have this BP underscore fluid sim01 and let's drag that into our world anywhere relatively close to the water really doesn't matter and the first thing is Select that fluid Sim in the outliner and then in your details panel so scroll down scroll down scroll down you want to get to this where it says show simulation mesh and check that and you should then see a blue mesh just like that and if it's hiding into your landscape you can just drag it up a little bit I'm going to put it as close to the landscape as I can but just above it and this is the way you can see where our fluid simulation is actually going to take place and the first thing I did when I was testing this out is I scaled it up to something massive and I did that with the simulation World size here like I scaled it up I think to like 60 000 because I figured why not cover the entire island with this and you could do that but the problem is all the effects like all the Ripples and stuff are scaled up in the same way and you might think that sounds really cool like I was thinking of the asteroid scene from Deep Impact where it goes across the water but it didn't end up working that way like I found when I scaled this up the effect actually looked a lot worse and I bet it has something to do with the resolution here I bet I would have to crank up this resolution so if anyone experiments with that feel free to post in the comments below Unreal Engine recommends that we keep this relatively small and that we keep it around our player this follow player here and that way the effect is only seen around our player and it's not rendering everywhere across our level but for the purposes of what we're doing initially here just to get it up and running uncheck follow player and then that way we're going to be able to see it right here close to our beach alright so the next thing we need something to interact with our fluid Sim here so for that go back to our content to our go to examples and then drag in a BP Dynamic Force component right about there and if you have that Dynamic Force component selected in your details panel over here then what you'll see is we can change the radius of it so I'm going to make it a lot bigger maybe like 200 and then we see a glass there we see kind of a transparent sphere and I'm just going to say show mesh and we're ready to test this out now so if you go to the dot dot dot over here make sure simulate is selected here and then you can go ahead and hit play and then when you're simulating you can just select that mesh and drag it around and you should get some wild effects something like this but you'll notice when you drag it outside the volume when I drag it outside the fluid Sim nothing it's only inside the fluid Sim here and again just make sure you have simulate checked here because it's not going to work otherwise and you'll notice that the water was going crazy there kind of spiking up in the air so what I'm going to do just to change this for now just to get a better effect we're going to do a strength of 0.1 on the dynamic actor here and now let's test again so we notice that the effect is much much lesser now and the other thing you can do is back in our fluid Sim I'm just going to scroll down and uncheck that show simulation mesh and then you get a more accurate representation of what it's actually going to do so if I drag it around boom boom boom but now let's Crank that up to maybe 0.5 I think I got the best effect at about 0.5 when it was a size of 200. all right so here we go with 0.5 yeah so it's still pretty strong right the water just shoots up but you got to keep in mind that everything that's moving in the world it's not going to move that fast well typically but let's go through some of the other settings that I found to be useful here so under our fluid Sim itself if you scroll down a little bit so the fluid Sim itself has two different types of fluid simulation we have a ripple solver and a shallow water we're going to get to shallow water in just a minute but let's stick with ripple solver for now now the damping here is very interesting because it basically reduces the effect to the extent that you raise that up so if I crank it up to something really high like 0.5 it's not going to have much effect at all when I move that Dynamic Force component so if I select that move it around yeah it's like a really quick and nothing so back in the fluid Sim I'm going to reduce that down again to 0.05 but now let me show you the one other setting for the Ripple solver that I think is interesting so under Ripple solver here let me reduce the travel speed down to maybe like 0.2 and it just reduces the speed of those waves so let me show you so I select our Dynamic Force component and move it around and yeah so it's basically a much slower effect it still does the same thing but it just occurs at a slower rate alright so now let's go over to the other type of fluid Sim which is shallow water and it basically produces a lot of foam so we come up here to the solver and instead of Ripple solver I'm going to choose shallow water and then I'll hit play again select our Dynamic Force component and here we go and it's doing crazy stuff it is bugging out man so what's going on with our shallow water so what I found that we had to do is under our fluid Sim here and by the way I should mention that whenever you change something when you're simulating when you stop simulating it's not going to keep those changes so you have to stop simulating first and then you can change something in the details panel so in our fluid Sim here I'm going to come down come down come down and the first thing I'm going to do is raise our travel speed up to a normal speed for ripple solver I don't think that's going to matter for our shallow water Sim but I'm just going to put it back to normal but if I expand shallow water here we see we have this default water depth of 50. now I found that unless this was lowered below 10 it had that crazy spiking effect because it's not designed for water that isn't that shallow so 50 is 50 centimeters it has to be below 10 centimeters so let me set this to like maybe eight centimeters and we'll try it again so I'll select our Dynamic Force component and there we go so now we have some foam and even still we still get some of that biking so let's lower it even less so I'll move it down to maybe five try again there we go and in general I found problems with this because it stopped working after a short amount of time so I don't know if that means I'm doing something wrong or what's going on there but we're not actually going to use that shallow water Sim in this game so I think we're okay but I think it might work well for things like bullets that are hitting water so if you have ideas to make that better please post in the comments below so I'm going to stop this let's go back to our fluid simulation and let's change it back from shallow water over to Ripple solver and let me actually crank this up to like sixty thousand and let me show you the effect that that has so we could say show mesh just to make sure that it's giant yep it's giant so now let's give it a whirl so select your Dynamic Force yeah so now we have huge huge ripples so if I were trying to simulate that asteroid shooting across the ocean that's what I would do but you'll notice that the resolution on it is very low it just doesn't look great now I tried cranking up the resolution here to eight-fold and that almost crashed my computer so I don't recommend changing this resolution and I tried a whole bunch of things to get a better effect but quite frankly wasn't successful I tried things in the terrain mode here so I tried changing this from terrain water depth only terrain with elevation you've seen capture death I was not able to get any of these working or working any better than what constant water depth was already doing the other thing I tried to get working and failed so let me just delete out our Dynamic Force component for a moment and go into examples I think this BP Dynamic Force scale mesh is actually broken so I drag this into the world I put it in the water put it in the right place did everything right and then it's walking and there's nothing even if I move it around absolutely nothing I tried maybe a dozen things to get this guy working and it just didn't work so I suspect it's broken on 5.1 and let me just show you the difference between these two so if I go into the dynamic Force component it's very simple so we've got to go back to our construction script and as a single component that's a force mesh and that's basically I think just a static mesh and all it's doing is it's setting the world Scale based on the radius and then setting it to be hidden in the game or not based on that setting show mesh and then in our event graph so on event begin play then it gets the simulation basically it gets the actor of class and sets that and then after that it's just making fluid Force Dynamic with these settings here and this is basically doing nothing the skeletal mesh setup because all this is blank and then it's saying register a dynamic force and that's our simulation that we set here and this get SIM and then it's doing that on the force mesh one thing that you might need to adjust is make sure that your water level is roughly in line with this setting here I tried to make my landscape water level literally at zero so no lower than zero make sure it's not below zero but try to keep it at zero or just above and then for the skeletal mesh component it's basically the same thing but it just doesn't work so back to our event graph I tried adjusting the water level here I tried adjusting all this stuff nothing worked so the way we're going to make this work for our skeletal mesh component is we are going to spawn multiple Dynamic Force components and assign them to various bones or sockets on our mesh and I thought this might be performance intensive but it wasn't bad at all maybe like one FPS so I just disregarded the dynamic Force skeletal mesh asset completely but before we do that before we get these forces working on our skeletal mesh I just want to show you one more thing so close out of these and I'm going to close out of this guy and after you delete out that skeletal mesh just drag in our Dynamic Force component again make sure it's still working because I found that dragging in that skeletal mesh component often broke things so I'm going to select our fluid Sim again and I'm just going to select the show simulation mesh again set that back to a normal value 2048 and back on our Dynamic Force component just select show mesh so that it shows mess when we simulate and then drag it around and see if it's working and it's not working right because the skeletal mesh component broke everything so what I'm going to do is Select our fluid Sim delete that out we'll drag in a new fluid Sim and then it'll work just fine BP fluid Sim drag it in and then I'm going to set it back to show simulator mesh it's right there and then let's test it out again and it's not working so if this happens to you drag it in you reset everything you're like it's still not working so what's going on is just make sure to uncheck that follow player checkbox because otherwise it's going to go to wherever your player wherever your player start is as soon as you simulate so uncheck that follow player try it one more time should be up and running there we go all right so if you've got it up and running let's delete out our Dynamic Force component just for a moment and instead we're going to do one last thing before we start working with our character so under examples we're going to drag in a fluid impulse repeating because this one I found works just fine in the fluid Sim I'm going to uncheck the show mesh and then hit play so if you zoom in very closely you could see it go there it goes boom and we've also got a trigger button right here so trigger boom and if you expand under IMM settings it's misspelled here because it's experimental immol settings we can change the radius we can change the strength so I'm going to change this to like let's do negative 10 so it doesn't Spike as much and maybe the radius a lot bigger 640 and then let's hit trigger boom boom yeah so that would be cool if there was like an underwater earthquake and you want the whole world the whole ocean to like shake a little bit so you get the idea with this fluid impulse repeating I think it's a pretty cool effect we're not going to use it this episode but I wanted to show it so let's stop the simulation delete that out of our outliner and now let's get the fluid Sim working with our character so first thing let's make sure that our fluid Sim actually follows our player so if you scroll down in the fluid Sim let's check follow player here and I'm also going to say show simulation mesh just so I could see where it is and then what we'll do right click play from here and what we should see is that the fluid Sim moves with our player so it moves out into the distance and then it comes back exactly where our player is going so let's exit out of that we'll go back to our fluid Sim I'll uncheck the show simulation mesh here and then let's go into our third person character blueprint so back over to all content core third person character and like I said the way I got this working is in event begin play literally at the end of event begin play so all the way over here I just spawned one of those actors from class the dynamic component actors so at the very end of the begin play string of our third person character we are going to spawn actor from class and the class is going to be BP underscore Dynamic Force component right there for the spawn transform I'm going to get our mesh here and get the transform of our mesh so get World transform right there connect this up and the other thing I did is from instigator here I just got a reference to self I don't know if this is necessary but I did this both for the instigator and owner Collision handling override I set this to always spawn ignore collisions and so when we spawn this we need to tell it where it's going to be attached to like what part of the body and so first let's get this up and running just with our simple footstep effects so from the return value here I'm going to do attach actor to component and the component we're attaching to the parent is going to be our mesh connect this up and we need to attach it to a socket here and so if you go into your mesh so I'm just going to expand the details panel a little bit go into this and if you scroll down scroll down scroll down so we created foot sockets I think it was maybe back in episode 20 something like that yeah Foothill socket here but the problem that I noticed is that these sockets are at the back of the foot and really I want these effects to start at the front of the foot I just found that it looks a little bit better so we're going to create some new sockets so we'll right click on our foot add a socket and now it's foot L socket without a space and we can just select up here to transform it I'm going to move it all the way to our toe and just make sure you got that centered appropriately a little bit down something like that should be good all right so we got a socket for our left foot now we need a socket for our right foot so we'll come down right click on foot R add a socket do the same exact thing here so move it up move it down a little bit over doesn't have to be perfect that's fine save that make sure you got the exact name of your socket so foot underscore r capital S for socket and this one's going to be left socket so foot underscore L capital S socket and under location rule here as soon as it spawned I'm going to snap to Target so then we're going to replicate this exact same thing for our right foot so paste all that connect it up and then over here foot our socket so we're ready to test this so compile and save and then we'll do a play from here and now we got the start of our ripples there but the problem is when I go into deep water it stops working because we only have two of them attached to our feet so it's only when our feet are close to the surface of the water so what I'm going to do to solve this is really simple so back in our skeleton we're going to add two more sockets to our calves cap L and cap R they're basically at our knee level so right click here add socket calf L socket that's totally fine position and then we're going to do the same thing with kafar so right click add socket save that back to our third person character and we'll take all of these and copy it once again move it over connect it up this one is going to be the calf L socket and this one is going to be the calf R socket compile that and we're going to do one last one we're going to do one at our pelvis because I found that moving around at waist level we still want the effect so I'll come all the way back up to our root well close to our root pelvis right here right click we're going to add a socket pelvis socket no underscores so we'll just copy one of these paste it in connect this up pelvis socket one word and the other thing I'm going to do here for the pelvis one is I'm going to make it a little bit bigger because our legs you got to Envision they're only a few centimeters wide but our pelvis is a lot wider so we want that to be bigger roughly twice as wide so I'm going to set the radius on this to be instead of 10 which is the default for that component we're going to set it to be 20 and then attach it up here put in a little reroute there all right so if you got all that if you got your five sockets if you're attaching it to each of those sockets and actually what I'm going to do is make some space just to separate out the stuff we've got from previous episodes and compile and save and we're ready to do I hope a final test and that's working pretty well even in deep water so we get the Ripples and it's looking pretty good right but you still don't have the sound effects or the Niagara Splash effects that you saw on the intro so for that we're going to leverage all the setup that we did back in episode 20 and 21 of the series so back in episode 20 of our series if I go back to content I search for SM underscore water plane so this water plane here we set this up and I'm going to make this a lot larger charger just for demonstration purposes here so 10 by 10 and the other thing I'm going to set here just so that it's invisible when we play is if I search for hidden in game I can check that and then if I right click and say play from here yeah so now we've got our water sounds we've got our Niagara particles everything's working from episodes 20 and 21. and by the way if you don't want to check out the whole episode let me just give you the Bare Bones basics of what we did to set that up so in our water plane here if you go into the static mesh itself what I did under the static mesh is I set our Collision presets to water body collision and what that's able to do is it prevents our character from stepping up on it but it allows our line Traces by profile to hit it and then we compare line Trace by profile location to the line Trace by Channel location which is the landscape under the water and that gets our water depth and then based on our water depth we can play a different sound we can play a different effect and the other critical part of this other than the Collision presets here is that within our material itself within this Mi water one we have to give it a physical material of water underscore PM so again we set this all up in episodes 20 and 21 which are water sounds and effects episodes but the point is we get this set up in one place and we can work it everywhere so you don't need these tabs anymore we can close these out and what I'm going to do now is I'm just going to scale up our meshes so that the entire surface of our Island basically all around the edges I wish I could just do it in one but I don't want this to be in the very Center in our cave we set up last episode so I'm just going to scale up a series of these all around the edges of our Island and we'll be good to go with water all around the edges and one important point to get the best Niagara Splash effects I set this to be just above about five centimeters above the surface of our ocean because in certain places we got the ocean waves coming up a little bit so that five centimeters it gives it a little bit of cushion so we still have some Splash effects so I'll set this to Z5 and then scale I'll move this to let's do like a hundred times as big and then we'll position a bunch of these and you want to watch out for places of your beach that actually go below the water line because then you get something like that so just move it out until it's actually on your beach and you can make smaller meshes as needed to fit into those weird spots if there's some overlap totally fine so that's looking good so you can test out playing anywhere on your level so right click play from here and you got footstep effects up and running one really quick thing I don't think this matters in any regard but I want to mention it in this episode just in case it does so if we go all the way down to our water Body Ocean and I'm just going to go into my water Body Ocean material actually the parent material so we got to go over here and then scroll down scroll down scroll down go into this material and then one more scroll down scroll down scroll down this material here water underscore material so if I come over to the left here one thing I did is I enabled foam under the fluid simulation here so all I did to do that was I right clicked on here promote to parameter checked it by default and I'm not sure that matters in anything I did but I found that setting this in the material in any project then sets it in all my projects because I think the standard materials like this water material are shared across projects so I wanted to mention that in case you're not getting the effect this might be the cause so we're all set here I'm going to close out of all of these and we will need our third person character up and running because the final part of this episode we're going to get this interacted with our gameplay abilities and specifically I'm thinking about two abilities in particular that we've set out in episode it's 27 and 30 I believe respectively that was our flamethrower and our Fireball and in regard to the flamethrower I got this working pretty close to perfect but in regard to the fireball a lot remains to be desired and I'll explain the limitations and the things that I encountered that quite frankly I didn't know how to solve so what we're going to do is on our third person character here we're going to come to the end of this string we're going to create one more of these so I'm basically going to take all of this that we set up for our pelvis copy that paste it one more time connect this up but what's unique here is instead of connecting it to our pelvis I'm not going to do that I'm going to delete this out I'm going to move this out delete this and instead from this return value here we are going to right click promote it to a variable and I'll connect this up I'm also going to connect up the variable just like this so This variable down here on the left I'm going to right click rename I'm going to call it the primary Dynamic Force component so we are always going to have on our third person character a primary Dynamic Force component that's going to move depending on the forces that our character is exerting so in the first case that we're going to set up it's going to be the flamethrower so I'm going to come pile and save this and then we've got to go into our gameplay ability fire so that's over to blueprints here under gameplay abilities and gameplay ability fire and we started this back in episode 26. so what we're going to do here on our event graph so I'm going to zoom out and we're going to come into our activate fire ability our channeled fire abilities which is our flamethrower I'm going to come down to the end of that chain and what we need to do is we need to first start by setting an actor location set actor location and the actor that we're going to set well it's that primary Dynamic Force component so we need to get a reference to our third person character get third person character reference and then from that I can get our primary Dynamic Force component and that's going to be connected up to the set actor location here but then we need to set this location so what I'm going to do is from the third person character I'm going to get World location and we have to get it for our particular component I'm just going to choose the capsule so just like that get word location connect this up here and the reason I'm setting the location again anytime it gets activated is so that it's always on our character and then we need to set the strength of our primary Dynamic Force component we're going to update that every time we activate our flamethrower so that it reflects how strong our flamethrower is so for that I'm going to get the intensity of our gameplay ability I'm going to divide this by 100 because we don't want it to be a hundred times as strong as the typical intensity because the typical is 100 and then I can get a reference again to our primary Dynamic Force component and from that we can set the strength and connect this up here connect this up here so compile and save this and now as our flamethrower is going we need to update the location that this primary Dynamic Force component is actually going to be in we need to get wherever the flamethrower is hitting the water if it's hitting the water and then update that location so that it kind of traces the path of the flamethrower and so what I'm going to do I'm going to zoom out here I'm going to come up to event tick and we actually have to do this on event tick because we want to do it in real time as the flamethrower is moving but we only want to update this on a vent tick if certain things are going on so what I'm going to do is a branch node and we're going to make sure it meets a certain set of criteria before we do this otherwise it's going to be more performance intensive than it has to so from the condition here I'll do an and so there's a few criteria that we need to check and for that I need to get a reference to our animation blueprint animation blueprint third person character reference we need to check first is our character spell casting standing still the second thing is we need to check is our character standing still it's about casting standing still and last but not least for this particular gameplay ability we don't want it to activate too quickly we want to check to see okay is it able to be activated or deactivated because there's about a half second pause where the character is kind of like they're going backwards charging up the flamethrower before the flamethrower actually starts and we don't want the effect to be on the water until the flamethrower is actually going and that's what this accomplishes so I'm actually going to add a pin here and then we can connect up all three of these and move these over a little bit move these over a little bit and so then the question becomes all right if all of these are true meaning our character is casting a flamethrower how do we tell where to move that Dynamic Force component and for that we need to get a location where our flamethrower is actually hitting the water and the way I'm going to do that is I'm going to do a line Trace basically from our characters chest through the hands like through the arms of our character because that's the direction in which the flamethrower is being aimed and I thought about doing this on the Niagara system itself but the problem is the Niagara system is not colliding with the water it's not using water body collision and so I realized we could just do a simple line Trace here and it'll work just fine and so for that I've got to get a reference to our third person character again so not our animation blueprint but our third person character and from that I need to get our mesh get mesh and we need to get the location of two different sockets really two different bones really our chest and then our hands because that's the direction in which the trace is going to continue forward so I'm going to get socket location get socket location in this get socket location this also works for bones but this is going to be our hand underscore our socket sockets capitalized and then the second one we're going to do if I copy and paste this connect this up to the mesh this is going to be our spine underscore zero five and we don't need to use a socket here this is just our spine bone the reason I'm choosing spine zero five is it's pretty high up it's close to our neck basically at our chest level and then that way it's an accurate reflection of the aiming of the the flamethrower alright so what I'm going to do is I'm going to subtract one of these from the other connect this up and that's going to get the distance between them but also the direction which is our vector and then the question is how far out do I need to do the trace and I decided roughly 10 times the length of this so if you think of like 10 times the length of the arm that's about how long our flamethrower is going to move out so from this I'm going to drag out a pin we're going to multiply so I can search for asterisk and multiply I'm going to multiply the X the Y and the Z by 10. and so if this is true coming all the way back to this condition now so if this is true then we are going to do a line Trace by profile this one because that's going to hit our water body and it's going to start right here at our hand socket and then it's going to end not at this it's actually going to end at the combination of the start plus this so we can do an add connect this up and connect this up here but there's actually going to be a problem with this and let's test this out to start though so I'm going to do draw debug for duration we're going to compile and save this and let's test it out I'm just going to show you why it's going to be a problem and to test this we actually have to get gameplay ability pickup actor into our world so back to blueprints gameplay ability pickup we can drag in our gameplay ability pickup actor and we need to set all the things that we need for it so we can search for our Niagara system display flamethrower pickup ability icon flamethrower ability types fire intensity let's set it to 100 which is the standard ability primary Niagara system flamethrower flamethrower with up how gameplay ability is used is going to be a channeled spell if you're not following this series this part you're going to say what's going on we've done this over a series of episodes alright so now we can right click we can say Play From Here we can pick up our flamethrower and so now you're going to see the line traces forward line Traces by profile so one the problem is you see how it's turning green right at our hands the problem is the line traces are hitting our character's mesh so we have to actually start to line Trace ahead of our character so it's outside the mesh so for that we'll go back to our gameplay ability fire and very simple here's what I'm going to do I'm going to divide this by two and I'll kind of explain why I'm doing this I'm doing a shortcut and explanation here but what I found is if I started it a little bit too far out then there could be the case where the flamethrower is hitting the water it's very close to our player and it's doing nothing but if I divided this by two it was perfect and then what we're going to do is we're going to add this to this location so basically what it's saying is half the distance between our hand and our chest take half the distance add it to our hand and that's where we're starting the line trace and so it's not going to collide with our player that way and connect up the start here and if this is messy I'm sorry guys I'm going to try to clean this up a little bit a little bit better compile and save Let's test all right we got our flamethrower here we go yeah so then we see it hitting the surface of the water there all of those red squares are a hit on the surface of the water and we see that it's starting just a little bit out relative to our hands so that's exactly what we want all right so now the question becomes when we do our line Trace what are we doing after if we get a hit so first we gotta ascertain are we hitting water and the way I'm going to do that is I'm breaking our hit result and then from the physical material that we're hitting we are checking to see with equals equals are we hitting water so I could search here for water underscore PM water physical material now if this is not water we're not doing anything with this we're doing nothing at all but if it is water then what we're going to do is we're going to set an actor location because that's what we're doing with our physical actor so we can once again get a reference to our third person character get third person character reference we've got to get our primary Dynamic Force component and we can connect this up right here and then we have to take our location our impact right there connect this up there you could also try impact Point as well but I found location works just fine I'm going to collapse this just for Simplicity now this is not going to work perfectly but I'm going to explain why and how I addressed it so compile and save this one more test all right so what's going to happen is it's going to spike like crazy so here we go yeah see those giant spikes out there so let me show you what's causing that and how to fix it so what's causing that is we are instantaneously changing our actors location and so what I decided to do to try to remedy this is I did a v interp 2 which slowly changes our Vector over some period of time actually it's a quick change but it's slow in computer speed the other thing I'm going to do here before we do that is I'm just going to turn off the draw debug for duration because we know that that's working and this way we could see the water now more effectively okay so from the location here what we're going to do is get V and terp2 and I'm going to move this out a little bit too because what we're interpolating to is our current location of the primary Dynamic Force component we're going to get the world location of our Force mesh here and that's the current one but then we're moving to our Target and our Target is wherever our flamethrower is hitting so that's the location here and then we can connect this up here but we got to tell it over what period of time and how quickly and you could change these settings but I found that a Delta time of about 0.2 and an interrupt speed of about 0.5 it worked well no more spiking of the water and what I'll do just clean this up a bit move this over here move this over there maybe move these in a little bit move this over move this up a little bit cleaner okay compile and save hopefully final test of our flamethrower Moment of Truth voila so if it's still too much spiking if you don't like the effect because it's still kind of spiky then you could turn down those settings but the settings that I would play with are the V interp 2 settings so play with the Delta time play with the interp speed see what you get if you get a better result please post in the comments below so now on to the final part of this episode and quite frankly the thing that I did not get working nearly as well as I wanted to and that's our Fireball because what I was envisioning is that the fireball could go over the surface of the water and the water would just as the fireball is moving out into space the problem is we already have a simulation mesh that's around our player and that only goes about 10 meters out past our player and so I tried all sorts of things to make this work I tried making a second simulation mesh attaching that to the fireball that didn't work I tried making the simulation mesh way bigger that didn't work I tried making a duplicate blueprint of the simulation mesh that could be generally all over the world that didn't work and I tried having two Dynamic Force actors like one that was on our Fireball and was moving with it in addition to the one that we already set up on our third person character and that didn't work the dynamic Force actors didn't work well together so I ended up almost giving up on the entire Fireball effect but what I did at least is I said it so that our Fireball does make the ripples when it's close to our player and I did that with the same primary Dynamic Force component variable that we just set up so it's really simple but it doesn't do all that much so I'll show you how I set that up and if you have better ways of doing that please let me know in the comments below and if you make your own video then I'd love to point to it so we got to start by going into our Fireball actor so that's over in Blueprints and Spawn from abilities BP Fireball here and what we got to do is over in our event graph so over on our event begin play we first need to get a reference to our third person character because we never set up a reference to our third person character on our Fireball so we've done this a billion times so you right click get player character not a billion maybe a thousand get player character here and then we cast to our third person character BP third person character connect this up here as BP third person character right click promote to variable we've got our reference so I'm going to right click here we're going to rename our third third person character reference and then following that getting of the reference what we can do is we can get our capsule component from that and we're also going to need to get our primary Dynamic Force component to get primary Dynamic Force component and that's going to be set after location set actor down here location connect this up and the capsule component get World location and we're going to set this here we're doing that so that when our Fireball is spawned then we're setting it to be close to our character close to our Fireball alright so now once we did that then we got to go over to event tick again and we've got to get the Collision capsule of our Fireball and from that we've got to get our world location and this is going to be the start of our line Trace by profile down because if the fireball is going over the water we want to know how close it is to the water so we're going to do a line Trace straight down and if it's within a certain distance then we're going to move the dynamic Force component so line Trace by profile and then from this I'm just going to do 200 units down so we're going to subtract and Z we're going to do 200 connect this up here connect this just there move all these down a little bit and next we have to come over here to the right and from our out hit we'll break the hit result and we'll do the same thing we did on our flamethrower so from our physical material we'll check to see is that equal to water underscore PM our physical material I'll collapse this move this in this is going to go out to a branch connect this up and what I can do is back in our gameplay ability fire I'm literally going to copy this exact same thing so copy all that come over to our Fireball paste it in and just make sure that your name here third person character reference matches third person character reference here because if they're different between the gameplay abilities and the fireball then it's not going to compile so connect up true and very easy to forget make sure to connect up your target so I actually have to expand the hit result location hooked up to Target collapse this make sure you got that connection got all that compile and save but before we test we need to copy our gameplay ability for our flamethrower and we need to change just a few things so this is going to be over to Fireball pickup ability icon over to our Fireball and our ability primary Niagara system is our Fireball Fireball with up and this is not a channeled spell single cast all right so here's our Fireball yep and that's the extent of what I was able to do just those ripples as it's being thrown out and our flamethrower still working one question I got for you guys I'm kind of neutral on how we handle this but our Fireball explodes under the water so post your ideas in the comments below so to finish out the episode you know how this goes guys let's go over to our third person character and on event begin play everything that we just set up we're going to take all of this and collapse to a function right click collapse to function move it in and for this so I'm going to rename it set fluid Sim Dynamic actors and we're going to categorize it under a new category of water compile and save that and we are done with our third person character so over to gameplay ability fire so I'm going to zoom out here and on aventic everything here on out we're gonna right click on that collapse to function and this one right click rename this is going to be check and update Dynamic force over water and I'll zoom out again and come down down here and this is under activate fire ability right there and specifically the channel string so we got to take all of this and same thing collapse to function and this one is going to be activate Dynamic force over water pile and save this done with gameplay ability fire last but not least our Fireball so event tick same kind of thing take everything there on a vent tick right click collapse to function and same kind of name so check and update dynamic force over water and zoom out again and on event begin play so everything passed or cast of BP third person character everything here right click collapsed function and this is going to be if I rename set Dynamic Force component compile and save this so that concludes our episode for today and now that we've done full fluid interaction with outdoor water I figure it's about time we start doing the same exact thing with indoor water and also with our gameplay abilities so I hope to see you there next episode
Info
Channel: NumenBrothers
Views: 22,096
Rating: undefined out of 5
Keywords:
Id: J3BlkZF0484
Channel Id: undefined
Length: 36min 44sec (2204 seconds)
Published: Sat Feb 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.