Ok, for some reason my player is still
falling through the floor.
even with collision on.
i implemented ur code best i could
Rem Project: loop
Rem Created: Tuesday, May 18, 2010
global Falling# as float
global TruckMesh=2
global loopmesh=1
global Speed# as float
global cameraon
cameraon=1
global gravityon
gravityon=0
global nx#
global ny#
global nz#
global coll
global gravity#=2.5
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+100,0
set shadow shading on 2
set shadow position -1,-100,500,-100
REM NEW!!!
global camang as float
set global collision on
automatic camera collision 0,1,1
automatic object collision 1,5,0
set object collision on 1
automatic object collision 2,5,1
set object collision on 2
for l= 1 to 100
_load_bar(l)
next l
do
GoTruckGo()
if cameraon
set camera to follow object position x(2),object position y(2),object position z(2),camang,200,4,10,1 REM EDITED!!!
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))
text 10,70,"xpos:"+str$(object position x(2))
text 10,90,"ypos:"+str$(object position y(2))
text 10,110,"zpos:"+str$(object position z(2))
text 10,130,"nz#:"+str$(nx#)
text 10,150,"ny#:"+str$(ny#)
text 10,170,"nz#:"+str$(nz#)
text 10,190,"coll:"+str$(coll)+":"+"gravity:"+str$(gravity#)
sync
loop
REMSTART
DO
if gravityon=1
gravity#=gravity#+.1
rotate camera 0,-180,0
point camera object position x(2),object position y(2),object position z(2)
move object down 2,gravity#
rotate object 2,0,-180,0
cameraon=0
if gravity#>10
gravity#=10
gravityon=0
endif
else
cameraon=1
endif
player()
if cameraon
set camera to follow object position x(2),object position y(2),object position z(2),camang,200,4,10,1 REM EDITED!!!
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))
text 10,70,"xpos:"+str$(object position x(2))
text 10,90,"ypos:"+str$(object position y(2))
text 10,110,"zpos:"+str$(object position z(2))
text 10,130,"nz#:"+str$(nx#)
text 10,150,"ny#:"+str$(ny#)
text 10,170,"nz#:"+str$(nz#)
text 10,190,"coll:"+str$(coll)+":"+"gravity:"+str$(gravity#)
sync
LOOP `pardon the pun :)
REMEND
function GoTruckGo()
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
if keystate(30)
turn object left 2,1+1
endif
if keystate(32)
turn object right 2,1+1
endif
turn object right 2,camang
T_oldx#=object position x(TruckMesh)
T_oldy#=object position y(TruckMesh)
T_oldz#=object position z(TruckMesh)
move object TruckMesh,Speed#
move object down TruckMesh,Falling#
inc Falling#,0.1
x#=object position x(TruckMesh)
y#=object position y(TruckMesh)
z#=object position z(TruckMesh)
Collide#=SC_RayCast(loopmesh,T_oldx#,T_oldy#,T_oldz#,x#,y#,z#,0)
if Collide#>0.0
x#=T_oldx#
y#=T_oldy#
z#=T_oldz#
pitch object up TruckMesh,sc_getcollisionnormaly()-object angle x(TruckMesh) `this will cause your truck to rotate as it goes around the loop. You may need to tweak it to make it right.
move object TruckMesh,Speed#
dec Speed#,0.01 `this symulates friction. you can take it out if you want.
Falling#=0.0 `trust me you need this here. You may have to change it to dec Falling#,some value to not completely counter gravity....
endif
endfunction
Function _load_bar(percent)
horiz_offset = 0
vert_offset = 100
Ink 0,RGB(255,255,255)
Cls
Ink RGB(50,50,100),0
Line (Screen Width()/2 + horiz_offset - 152),(Screen Height()/2 + vert_offset - 17),(Screen Width()/2 + horiz_offset + 151),(Screen Height()/2 + vert_offset - 17)
Line (Screen Width()/2 + horiz_offset - 152),(Screen Height()/2 + vert_offset + 16),(Screen Width()/2 + horiz_offset + 151),(Screen Height()/2 + vert_offset + 16)
Line (Screen Width()/2 + horiz_offset - 152),(Screen Height()/2 + vert_offset - 17),(Screen Width()/2 + horiz_offset - 152),(Screen Height()/2 + vert_offset + 16)
Line (Screen Width()/2 + horiz_offset + 151),(Screen Height()/2 + vert_offset - 17),(Screen Width()/2 + horiz_offset + 151),(Screen Height()/2 + vert_offset + 16)
Ink RGB(100,100,100),0
Box (Screen Width()/2 + horiz_offset - 150),(Screen Height()/2 + vert_offset - 15),(Screen Width()/2 + horiz_offset - 150 + (percent*3)),(Screen Height()/2 + vert_offset + 15)
Ink 0,0
Center Text (Screen Width()/2),(Screen Height()/2 - 50),"Please Wait"
Center Text (Screen Width()/2),(Screen Height()/2 - 35),"HellBorn: Wounded Prey Is Loading"
Center Text (Screen Width()/2),(Screen Height()/2 + 100),Str$(percent)+"% Loaded..."
Ink RGB(255,255,255),0
Sync
EndFunction
remstart
function player()
move object down 2,gravity#
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 gravityon=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
if ny#<=0.6 and ny#>0
` rotate object 2,0,90,0
gravityon=1
endif
else
rotate object 2,0,0,0
endif
` endif
if keystate(30)
dec camang
endif
if keystate(32)
inc camang
endif
turn object right 2,camang
endfunction
remend
function regplay()
move object 2,(keystate(17)-keystate(31))*4
endfunction
ignore anything with rem
any further fix would be appreciated
thanks, hawkblood!
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/