Make cube follow parent (player) on X & Z axis, but not Y?

In my game, I have a water plane, but when I go under the water level, it just looks like the water vanishes. I want an underwater effect similar to the ones found in many PS1 and N64 titles (Like Super Mario 64 - I don’t want fog) so I made a colored, translucent cube, and made it so the top of the cube is touching the water level. I want to make it so when my player moves, the cube follows and rotates with the player on the X and Z axes, but does not move above or below the y position I set in the object’s properties. How do I achieve this?

On the child node:

someNode.AddComponent(Rigidbody)
someNode.rigidbody.constraints = RigidbodyConstraints.FreezePositionY

//So obviously we add a rigidbody to the child, if you wish to not use physics then do.

someNode.rigidbody.useGravity = false
someNode.rigidbody.isKinematic = true

Place this script on your cube, assign “Player” in the inspector:

var player:Transform;

function Update(){
    // clone player's x/z, but not y
    transform.position=Vector3(player.position.x,
                               transform.position.y,
                               player.position.z);
}

EDIT: uh, you said your player is a parent of the cube? No, it won’t work for this script. Move the Cube somewhere in the hierarchy where it isn’t modified by other objects.