Ok simple bit of coding, nothing too taxing, using sparky's i have a simple "level" if you will with a sphere as player object, now firstly the player object just doesn't appear
global vx# as double float
global vy# as double float
global vz# as double float
global gravity# as double float : gravity# = -0.1
global slope# as double float : slope# = 0.5
global ground as integer : ground = 1
load object "Levels\Simple.x",1
SC_setupcomplexobject 1,1,2
Load object "Levels\Sphere.x",2
SC_setupobject 2,0,1
sc_drawobjectbounds 2
position object 1,500,500,500
x#=500
z#=500
y#=550
do
moveplayer()
set cursor 0,0
print "X pos ";x#
print "Z pos ";z#
print "Y pos ";y#
position camera x#,650,z#-150
point camera x#,520,z#
loop
function moveplayer()
yrotate object 2,object angle y(2)+mousemovex()/3
xrotate object 2,object angle x(2)+mousemovey()/3
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
angy# = object angle y(2)
vx# = 0
vz# = 0
if vy#=0 then vy# = vy# + 10*gravity# else vy# = vy# + gravity#
if keystate(32)=1 then vx# = vx# + cos(angy#) : vz# = vz# - sin(angy#)
if keystate(30)=1 then vx# = vx# - cos(angy#) : vz# = vz# + sin(angy#)
if keystate(31)=1 then vx# = vx# - sin(angy#) : vz# = vz# - cos(angy#)
if keystate(17)=1 then vx# = vx# + sin(angy#) : vz# = vz# + cos(angy#)
x#=oldx#+vx#
y#=oldy#+vy#
z#=oldz#+vz#
collide = sc_spherecastgroup(1,oldx#,oldy#,oldz#,oldx#,oldy#+vy#,oldz#,10,0)
if collide>0
ny# = sc_getCollisionNormalY()
if abs(ny#)>slope#
`Flat ground
oldy# = sc_getStaticCollisionY()
else
`Steep slope, cause to slide
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
endif
`ny#<0 means the player has hit a ceiling rather than a floor
if ny#>slope#
`only on ground if standing on flat ground
ground = 1
vy# = 0
else
ground = 0
`If player has hit a flat ceiling then stop vy# movement
if ny#<-slope# then vy# = gravity#
endif
else
`Nothing below player, not on ground, add vertical speed to player
oldy# = oldy# + vy#
ground = 0
endif
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,oldy#,z#,10,0)
if collide>0
`If hit, reposition player, stop movement
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
vx# = 0
vz# = 0
endif
position object 2,x#,oldy#,z#
sc_updateObject 2
endfunction
and secondly when i force the object to appear with a position object 2,x#,y#,z# command, the object won't move and i can't understand why
Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
I can see from your smile, you're not here for the sunset.