sync on sync rate 30 `Place somewhere at the start Global DH# : DH# = 15 make object cube 1, 10 do if upkey() move camera 1 endif if downkey() move camera -1 endif DistanceHide(0, 1) sync loop `This is the function you call Function DistanceHide(Camera_Number as integer, Object_Number as integer) if ObjectWithinCameraRange(Camera_Number,Object_Number,object size(Object_Number)*DH#) show object Object_Number else hide object Object_Number endif endfunction `This function is used by the above function function ObjectWithinCameraRange(Camera1,Object1,Range#) result#=(object position x(Object1)-camera position x(Camera1))^2+(object position y(Object1)-camera position y(Camera1))^2+(object position z(Object1)-camera position z(Camera1))^2 if result# < (Range#^2) then within=1 endfunction within