This command will lock the specified 3D object to the screen.

LOCK OBJECT ON Object Number
Object Number

The object position


This command does not return a value.


Locking objects to the screen commands the object to completely ignore the camera"s influence. A locked object will be positioned as though the camera had never been altered from its default orientation. To make locked objects visible, simply set the Z position to a significant positive value. The Object Number should be specified using an integer value. Be aware that locking objects performs a relationship between the object and the screen, not to a specific camera. Moving the camera, or creating new cameras will not affect the visibility and placement of a locked object, nor will the object return world space coordinates when locked to the screen.

Example Code
hide mouse:cls 0:autocam off




make object sphere SecondObject,1

load object "models\model.x",ObjectNumber

load image "iron.jpg",ImageNumber

append object "models\extraanim.x", ObjectNumber, total object frames(ObjectNumber)+1

set object interpolation ObjectNumber,50

position object ObjectNumber,0,0,0

position object SecondObject,0,0,0

position camera 0,2,4

point camera 0,0,0

while mouseclick()=0

set cursor 0,0

print "press k to lock object on"

if inkey$()="k"

lock object on SecondObject

position object SecondObject,0,0,5


print "press l to lock object off"

if inkey$()="l"

lock object off SecondObject

position object SecondObject,0,0,0


print "press up arrow key"

if upkey()=1 then move camera  1:while scancode()<>0:endwhile

print "press down arrow key"

if downkey()=1 then move camera -1:while scancode()<>0:endwhile

print "press left arrow key"

if leftkey()=1 then turn camera left 1

print "press right arrow key"

if rightkey()=1 then turn camera right 1


while mouseclick()=1:endwhile

if object exist(ObjectNumber)=1 then delete object ObjectNumber

if object exist(SecondObject)=1 then delete object SecondObject

if image exist(ImageNumber)=1 then delete image ImageNumber

Community content is available under CC-BY-SA unless otherwise noted.