You need to have collision boxes, and the
get object collision x() command will only return something if two objects are colliding, and you use the
object collision() for those objects:
rem setup screen
sync on
sync rate 60
backdrop on
color backdrop 0
rem make two cubes
make object cube 1,100
make object cube 2,100
move object left 1,100
move object right 2,100
rem make collision boxes
make object collision box 1,-50,-50,-50,50,50,50,0
make object collision box 2,-50,-50,-50,50,50,50,0
rem set starting position of one cube
objx=-100
rem main loop
do
rem move one cube towards the second cube
inc objx,1
position object 1,objx,0,0
rem check for collision
if object collision(1,2)
rem this command will only return something if two objects are colliding
print get object collision x()
rem refresh screen
sync
rem end of main loop
loop
TheComet [b]