Quote: "is there anyway i could
make it so it doesnt rely on point object?
cuz i need to be able to turn my player"
Looks like your player
is turning to me?
Do you mean you want to have the camera turn with the player? If so try this:
Rem Project: loop
Rem Created: Tuesday, May 18, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
position camera -200,200,-200
`load loopy world
load object "loop.dbo",1
yrotate object 1,90
sc_setupcomplexobject 1,1,2
`make a 'person'
global height as float
height=100
make object box 2,height/3,height,height/6
position object 2,0,height/2,0
set shadow shading on 2
set shadow position -1,-100,500,-100
REM NEW!!!
global camang as float
DO
if keystate(30)
turn object left 2,5
dec camang,5
endif
if keystate(32)
turn object right 2,5
inc camang,5
endif
set camera to follow object position x(2),object position y(2),object position z(2),camang,200,4,20,1 REM EDITED!!!
if object angle x(2) > 0 and object angle x(2) <= 180
player()
else
regplay()
endif
text 10,10,"x:"+str$(object angle x(2))
text 10,30,"y:"+str$(object angle y(2))
text 10,50,"z:"+str$(object angle z(2))
sync
LOOP `pardon the pun :)
function player()
REM Move player
if keystate(17)
move object 2,height/6
turn object right 2,90
move object 2,height/45
turn object left 2,90
endif
if keystate(31)
move object 2,-height/6
turn object right 2,90
move object 2,-height/45
turn object left 2,90
endif
REM Do ground check
`get start and end points for ray cast
oldx#=object position x(2)
oldy#=object position y(2)
oldz#=object position z(2)
pitch object down 2,90
move object 2,height
newx#=object position x(2)
newy#=object position y(2)
newz#=object position z(2)
move object 2,-height
pitch object up 2,90
`do the ray cast
coll=sc_raycastgroup(1,oldx#,oldy#,oldz#,newx#,newy#,newz#,0)
if coll<>0
`get collision data
nx#=sc_getcollisionnormalx()
ny#=sc_getcollisionnormaly()
nz#=sc_getcollisionnormalz()
`make an adjustment to z normal (cheating a bit here to make it work)
d#=sc_getcollisiondistance()
`adjust player angle to suit
point object 2,object position x(2)+nx#,object position y(2)+ny#,object position z(2)+nz#
`move 'up' to half height above ground
move object 2,(height/2)-d#
`re-adjust direction
pitch object down 2,90
if ny#<1.0 and nz#<0 then turn object right 2,180
endif
endfunction
function regplay()
move object 2,(keystate(17)-keystate(31))*4
endfunction
