I simply want to detect when the players head, or ill settle for camera, goes underwater so I can distort the audio. I am using the water plugin that comes with the engine. I thought this would’ve been an omega easy task but I’m utterly lost and my brain is fried and I can’t think anymore on it.
I could simply apply a water volume along the surface of the ocean but I have a good amount of waves and I want it to be accurate. The post processing for the underwater camera effect already registers this perfectly with wave height but I’m completely stumped on where it’s registering the camera collision and where its turning the post process on and off of the camera. If you hover over the “enable post processing” box in the waterbodyocean it states that it uses collision.
So perhaps someone with a bigger brain can figure out exactly where this is taking place and how I can apply a muffled audio effect along with it. Thanks
There is no such option unless you build your own wave system.
You can try to figure out what the ocean uses for wave calculations.
If you manage that, maybe you can modify or duplicate the function to return height values for you.
You want Z for X and Y at Gametime.
The post process doesn’t really need to know the height. It probably detects the water sheet with a stencil or similar to bring the effects into place.
Wouldn’t bark up that tree even if it somehow did.
Maybe you can fake this by placing a buoyancy pontoon on an invisible object that’s attached to the player but free to respond to waves. Then read off its Z value.
The cost of that is literally insane compared to what you need, so i wouldnt reccomend it outside of testing that your own wave reading solution is accurate…
I don’t think most Triple A games even bother with this amount of accuracy. I’m playing Cyberpunk 2077 2.1 and Spyro Reignited right now, and they absolutely don’t try this.
Just because AAA companies hire and foster inept developers doesn’t mean that individual developers have to complacently comply with their rather sad practices…
Where would Laryan be if they applied this logic?
I would try creating a trigger box actor and have it be right under the water. I would put the box a little bit under the water not right at the water so that way a player has to fully be underwater to activate the “trigger box” actor. In the trigger box blueprint I would do something like on beginoverlap when player touches the box that is under the water the audio distortion is applied. In the trigger box Blueprint you could cast to your player character blueprint and then handle the distortion there. Just duplicate the box actors in your level in order to roughly create the “shore” or perimeter of your body of water.
There are a couple YouTube tutorials that would better explain trigger boxes and how to setup “event begin overlap” and then you could also look up how to make a muffling audio effect.
Obviously this solution wouldn’t be able to work with waves above a certain point like you said you wanted but it is a simple one. Maybe you can make a custom trigger box spawner that goes along with your waves and their locations and heights but like others said this might be impractical. I also don’t understand why everyone is talking about Triple A studios when that was never mentioned before. People just like to make stuff sometimes doesn’t have to be the next Minecraft
Another user commented this:
" Maybe you can fake this by placing a buoyancy pontoon on an invisible object that’s attached to the player but free to respond to waves. Then read off its Z value. "
You could somehow make the trigger box follow the player instead and detect whether or not you are underwater. The “Interactive World” plugin is free and uses a brush against a texture to detect where you are in the world and interactivity with snow and ground. Maybe you could rig this to your game.
I agree with you, but you should watch the way you communicate with people.
My point is, it may not be worth their time to be this meticulous. Laryan kept laser focus, and executed it (mostly) flawlessly, instead of doing a bunch of things mediocre.
If this person is creating an experience that is specifically tailored to oceanic gameplay, it may be worth it.
But if the player isn’t spending all their time in the water, maybe not.
You know this, and I know this, but don’t talk to people like they’re idiots. You have no idea who’s on here.
Look for the functions NotifyActorBeginOverlap and NotifyActorEndOverlap in the WaterBody. In my project I overloaded those functions, then check the actor and call a custom ‘enteredwaterbody’ event when activated.
Look at the def of those functions in AWaterBody and how it does the buoyancy component call and copy that in your own class inherited from AWaterBody.
There may be a way to do this in BP, but I’m not sure. Unfortunately implementing swimming and water interaction isn’t turnkey but if you can code it’s all pretty accessible.
Also, check video tuts on swimming, they may provide alternate ways to implement this.
Thanks for all of the ideas guys! I won’t have time to sit down and attempt them until a little bit later. It’s not super important as I’m not even making a game based around this and was just playin around with the water plugin.
Had the character standing on a rock in the ocean and it felt bad that the camera registered the post processing underwater when the waves hit but couldn’t get the muffled audio to register with it lol.
I found this tooltip for the post processing settings and it mentions collision being required to detect camera underwater. I thought I might be able to access this underwater state with more ease but perhaps not!
Any idea how the default camera is able to detect if its inside a wave and add the post process material to the camera? or inside the water in general. Is it some complex material parameters?
Maybe if I can solve that I can just register underwater audio whenever the post process is turned on
Idiots make up 99% of the world, so chanches are idiots are reading. Well, if they are capable that is.
@vslash9
The guy above just gave you the exact code you need to make it happen right.
Just use that.
As I said,
The post process probably just happens in Screen Space - it has no actual relation to the wave height if not for the fact it sees and uses the wave’s mesh.
You cant go from a material or anything that happens GPU side to something - anything else - that happens CPU side, like audio or collision.
You could go from CPU to gfx, maybe. But that’s surely not how the system is set up, or they wouldn’t have the function mentioned above as an option.
The camera is using the material function for wave position to draw the water line, I believe. That function is nearly a mirror of the c++ one and used for material effects on the gpu, so unfortunately may not usable for your situation.
Yes the wheels are finally turning in my inferior nooby brain and after staring at the post processing volume material for a couple of hours I think I’m getting it.
Unfortunately my moist noobian noggin is not familiar with implementing C++ and just the thought of adding your code yet alone properly utilizing it makes me want to unleash my bowels in fear and screech out for the assistance of a strong masculine figure that posses superior intellect to hold my delicate body.
But that is a different issue that might one day require a different forum post. For now I have marked this as solved and will move on.
Ha! I get it. I was once there, staring into the code abyss myself. Like the materials, if you stare and play around long enough it will start to make sense.
More type and get it wrong a trillion times, but yes…
@vslash9
What’s the worse that can happen anyway? You brick the project?
Just keep a copy on hand on a separate drive. You should anyway out of habit.
Install Visual Studio Community and create a c++ class from within the engine.
It does almost everything for you.
To understand how functions in blueprint are made, you then usually doubleclick any engine function node and the relevant class definitoon or function call will open in visual studio.
To learn some, try looking at basic things in the Kismeth stuff.
Idk, say Atan2 for instance.
Make a node in the engine blueprint and doubleckick it.
Reead it and, yea at that point cry a little because its Atan2
From that though, look at the engine signiature on top - the function call header.
You probably just need to wrap the code you were given in somethinf silimar in order to make it a bleurpint callable function you can run from anywhere…
Note
CurrentWaterBody
Probably needs to be an Input pin
That means inside the top ( )
Where you get that from in engine… now that im not sure of.
Probably create a variable of that type on the actor, then expose it, then put the actor in the level.
And… like magic … you should be able to select it as the only option…