I have an ocean shader that uses a vertex sine wave to make waves on a grid mesh.
I have an object that I want to float in the ocean. I can use the exact same sine wave to get a y position for the floating object. I have done this in a shader for the floating object and it works perfect.
I have a water vehicle that I want to float in the ocean. I can use the exact same sine wave to get a y position for the floating object. But I can’t do it in a shader because I need the collision working and that gets all messed up. Therefore I need to do this using a script. And that’s simple. Except I can’t figure out how to sync up the time in the script to the time in the shader.
It depends if you are in play mode or not, otherwise EditorApplication.timeSinceStartup is what’s being fed to the _Time parameter in shaderland. While in play mode it’s Time.time. This what I use in my buoyancy script and it matches the _Time.x value used in shaders: