SET CAMERA TO FOLLOW This command automatically controls the camera to provide a tracking system.
Syntax
    SET CAMERA TO FOLLOW X, Y, Z, Angle, Distance, Height, Smooth, Collision
    SET CAMERA TO FOLLOW Camera Number, X, Y, Z, Angle, Distance, Height, Smooth, Collision
Parameters
    Camera Number
Integer The camera number
    X
Float The x value of the target object
    Y
Float The y value of the target object
    Z
Float The z value of the target object
    Angle
Float The angle value of the target object
    Distance
Float The distance value specifies the required distance between the coordinate and the camera
    Height
Float The height value specifies the required height of the camera in 3D space
    Smooth
Float The smooth value specifies the level of smoothing required for the camera, where a value of 1.0 is no smoothing and a value of 100.0 is lots of smoothin
    Collision
Integer The collision value is a special flag that allows the camera to detect whether it is hitting any of the static collision boxes and if set to one will automatically adjust so as not to enter these collidable areas
Returns
This command does not return a value.
Description
By providing the 3D world coordinate of the entity you wish to track, and some camera data, your camera will automatically update its current position each time this command is called. The X, Y, Z and Angle values provide the coordinate to track. The Distance value specifies the required distance between the coordinate and the camera. The Height value specifies the required height of the camera in 3D space. The Smooth value specifies the level of smoothing required for the camera, where a value of 1.0 is no smoothing and a value of 100.0 is lots of smoothing. The Collision value is a special flag that allows the camera to detect whether it is hitting any of the static collision boxes and if set to one will automatically adjust so as not to enter these collidable areas.
Example Code
    autocam on

    make matrix 1,4000,4000,100,100

    set matrix height 1,50,50,500

    update matrix 1

    make object sphere 1,10

    set camera rotation xyz 0

    set camera range 0,1,3000

    while mouseclick()<>1

    a#=a#+1 : if a#>359 then a#=a#-360

    x#=500+(cos(a#)*100) : z#=500+(sin(a#)*500)

    distance#=200.0 : height#=100.0 : smooth#=25.0

    dx#=x#-camera position x(0):dz#=z#-camera position z(0)

    angle#=atanfull(dx#,dz#)

    set camera to follow 0,x#,0,z#,angle#,distance#,height#,smooth#,0

    set camera to object orientation 0,1

    endwhile

    while mouseclick()=1 : endwhile

    delete matrix 1

    autocam off

    end
See also
CAMERA Commands Menu Index