You have refer the picked up object position and angle to the player object ( I guess it's object number 200)
to offset ahead you need to use :
rem ahead offset obj from player - 60 units ahead from player positions: x# and z#, player angle a#
objx#=newxvalue(x#,a#,60)
objz#=newzvalue(z#,a#,60)
if you want it offset also sideways:
rem side offset from ahead offset - 50 units
objrightx#=objx#+cos(a#)*50
objrightz#=objz#+sin(a#)*-50
position object objnum,objrightx#,h#+50,objrightz#:yrotate object objnum,a#
full example (very old code):
Rem * Title : pickup object
Rem * Author : Scorpyo
rem ********** MAIN 1 ****************
sync on:sync rate 60:sync
global Sw,Sh
rem Sw=1920:Sh=1080
rem set display mode Sw,Sh,32
load dll "user32.dll",1
Sw=call dll(1,"GetSystemMetrics",0)
Sh=call dll(1,"GetSystemMetrics",1)
delete dll 1
set display mode Sw,Sh,32,1
hide mouse
sync on:sync rate 60
autocam off
backdrop on
x#=10000
gosub Setupland1
gosub makecubes
gosub Character
gosub resetcam
set camera range 1,10000
set object collision to boxes 9999
rem *****MAIN LOOP******
do
rem check borders
if x#<100 then x#=100
if x#>landsize-100 then x#=landsize-100
if z#<100 then z#=100
if z#>landsize-100 then z#=landsize-100
gosub Playercontrol
rem call to camera changes subroutine ( bottom key row )
gosub camera_controls
rem Calculate position data
oldx#=x#
oldz#=z#
x#=newxvalue(x#,a#,s#)
z#=newzvalue(z#,a#,s#)
rem calls camera update subroutine
gosub update_camera
gosub printdata
gosub pickobjs
rem Update active model
h#=get ground height(1,x#,z#)
position object 9999,x#,h#+5,z#
yrotate object 9999,a#
rem Update screen
sync
loop
rem ** SUBROUTINES ***************************
pickobjs:
if holding=1 and mouseclick()=2 then holding=0:objnum=0:wait 50
For obj = 1 to 20
if object collision (9999,obj) and mouseclick()=1 and holding=0
holding=1:objnum=obj
endif
rem ahead offset obj from player - 60 units ahead
objx#=newxvalue(x#,a#,60)
objz#=newzvalue(z#,a#,60)
rem side offset from ahead offset - 50 units
objrightx#=objx#+cos(a#)*50
objrightz#=objz#+sin(a#)*-50
if holding=1 then position object objnum,objrightx#,h#+50,objrightz#:yrotate object objnum,a#
Next obj
return
rem ****** CREATE LEVEL ******
Setupland1:
landsize=20000:grid=30:mtxrandomize=1
make matrix 1,landsize,landsize,grid,grid
randomize matrix 1,mtxrandomize
update matrix 1
return
rem ***** PLAYERCONTROL *****
Playercontrol:
rem ****Character walk ****
if inkey$()="w" and s#<12 then s#=s#+0.5
if inkey$()="s" and s#>-12 then s#=s#-0.5
if inkey$()="a" then a#=wrapvalue(a#-1)
if inkey$()="d" then a#=wrapvalue(a#+1)
return
rem ****BUILD PLAYER****
rem object 9999
Character:
rem make cone
make object cone 9999,100
scale object 9999,80,100,140
rem point tip forward
xrotate object 9999,60
set object cull 9999,0
return
camera_controls:
if inkey$()="z" then camdist=camdist+2
if inkey$()="x" then camdist=camdist-2
if inkey$()="b" then camrot=camrot+2
if inkey$()="n" then camrot=camrot-2
if inkey$()="c" then camhgt=camhgt+2
if inkey$()="v" then camhgt=camhgt-2
if inkey$()="m" then camlen=camlen+2
if inkey$()="," then camrot = 180
if inkey$()="." then gosub Resetcam
return
rem camera update
update_camera:
rem Position camera to the back of the character
cx#=newxvalue(x#,wrapvalue(a#+camrot),camdist)
cz#=newzvalue(z#,wrapvalue(a#+camrot),camdist)
cy#=get ground height(1,cx#,cz#)
position camera cx#,cy#+camhgt,cz#
rem Point camera at object
point camera x#,y#+camlen,z#
return
rem camera reset
Resetcam:
camdist=-400
camhgt=400
camrot=0
camlen=200
return
printdata:
set cursor 0,0
print " holding=",holding
print " Left mouse = Pick"
print " Right mouse = Drop"
print " PickedUpObject=",objnum
print "-------------------------"
print " W,A,S,D to move"
Print " z,x,b,n,v,m, change camera values"
print " . = reset camera"
return
makecubes:
for n=1 to 20
make object cube n,100
cx#=rnd(20000):cz#=rnd(20000)
position object n,cx#,50,cz#
set object collision to polygons n
next n
return