I have a Material named “WaterMaterial” and a Blueprint called “Water_Surface”. The water material contains some math to set the World Position Offset which makes the material look like it’s splashing up down. Meanwhile, my blueprint as a Collision Box that is parented to the box I’ve applied the WaterMaterial to.
I need accurate collision on the water_surface, which means I need my collision box to move with the WaterMaterial box.
I’m struggling to find a way to grab the World Position Offset value. Is there any way I could do that through blueprints?
Attached is an image of the code that’s driving my World Position Offset value inside the WaterMaterial.
To make it clear, I just need help either getting the direct World Position Offset Value, or sending all this data into some kind of variable or parameter which I can access in Blueprint.
Getting the collision box to move is easy.
Hi, you can get the value of a scalar or vector parameter stored in a material via a blueprint, but there is no path to get a value solved by the material for a specific position like you are asking. It is still doable though with a different approach.
What you need to do in this case is replicate the sine waves in your blueprint and synchronize the time variable. You could try using “get real time in seconds” or better use a timeline or deltatime on tick in the eventgraph to increment a global parameter in a material parameter collection. Or drive a material instance dynamic. As long as time and the values of your parameters and math are the same, you will get accurate wave height. Also account for any additional Z offsetting that may need to come from actor position.
Thank you for the reply!
I’ve been having great difficulty setting this up in Blueprint. I’ve recreated the formula in blueprint, and applied it to an object “Vision Cube” which has the same size, shape and origin point as my water cube. I have attached my Blueprints below. The problem is that it’s not moving correctly; it’s moving too slow compared to the object with the water material applied, and when I speed it up by multiplying the “Game Time In Seconds” module, it doesn’t increase the Z (technically X due to the way the objects are laid out in the blueprint) value properly.
Can you determine what I’m doing wrong?
NOTE: The Plane shouldn’t affect anything and is disabled in game; it’s just there for reference.
This is most likely because the period of the sine nodes is not matching up. I think the sine in the material editor has a period of 1 or so while the BP one has a period of 2pi. Try setting them to the same thing.
Also not sure why you are adding the X for the water plane. I would keep it to Z offsetting in worldspace to remove any orientation issues.
Whenever in doubt of the time values, debug them. You can easily debug time in the material editor with “Debug Scalar values” and debugging time in BP is as simple as “print text” or my favorite making a text component show time by setting text to time.