Animated ocean for export

I’m fairly new to animation, so please forgive me if I’m not using the correct terms or am doing things in a weird way.

I’m trying to make an animated water terrain block for the Unity game engine. The following image is what I want:


The top surface of the block is a grid (probably much higher resolution than I’ll end up using, but I’m not worried about that for now), with the vertices shrink wrapped to an ocean object (hidden). This works great in Blender, but I have no idea how to get the animation data out to Unity.

I guess I somehow need to keyframe the location of the surface vertices, or even attach bones to each vertex? Is something like this possible? Any suggestions are welcome.

Well, I got something working in the end.

I added a small bone (tiny envelope) with a shrink-wrap constraint to project it onto the ocean surface. Then I duplicated it so that there was one at each vertex of the grid. Next parent block to the armature (using Envelope setting rather than the default), and add another bone assigned to a vertex group containing all the stationary vertices (otherwise Unity adds them to the first bone of the model). Then just export!

One thing I’m still having a bit of trouble with is the settings of the Ocean modifier. I really want a perfect loop, but there’re no settings to actually achieve that. I ended up just scrolling around to find the most similar point to the start that I could, and using that. It’s close enough that it’s not easily noticeable in Unity.

The other thing I have to play around with is the frame rate / keyframes. I actually don’t have any keyframes, and it exports fine, but the files are pretty huge, so I suspect I could probably cut down on that.