Preview:
global proc ifCubeAndSphere()
{
	string $cube[] = `polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
	string $sphere[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`;
	xform -t 5 0 0 $sphere[0];
	expression -s ($cube[0]+".translateY = noise(time*3)*10;")  -o $cube[0] -ae 1 -uc all ;
	expression -s ("if ("+$cube[0]+".translateY <0)\n{\n\t"
						 +$sphere[0]+".translateZ = sin(time*4)*5;\n\t"
						 +$sphere[0]+".translateY = 0;\n\n}\nelse\n{\n\t"
						 +$sphere[0]+".translateY = sin(time*4)*5;\n\t"
						 +$sphere[0]+".translateZ = 0;\n\n}")  -o $sphere[0] -ae 1 -uc all  ;

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter