Nope, I think the problem is here:
for w = 1 to 7
read posx#,posy#,posz#,sizex#,sizey#,sizez#
make object box 10+w,sizex#,sizey#,sizez#
position object 10+w,posx#,posy#,posz#
make static object 10+w
sizex# = sizex# - 2.5
sizez# = sizez# - 2.5
make static collision box posx#-sizex#,posy#-sizey#,posz#-sizez#,posx#+sizex#,posy#+sizey#,posz#+sizez#
delete object 10+w
next w
and here:
if static line of sight(posx#,posy#,posz#,tx#,ty#,tz#,1,1) > 0
tx# = static line of sight x()
ty# = static line of sight y()
tz# = static line of sight z()
endif
Because I set the accuracy to 1 and radius to 1, the intersection point was on the wrong place --> I resized the static coll box -2.5 in the hope it worked. It worked, but my collision didn't.
Now it's fixed.
I have set accuracy to 0 and radius to 0.001.
`collision demo
`static line of sight
sync on : sync rate 100
`create player
make object sphere 1,3
make object cylinder 2,1
xrotate object 2,90 : fix object pivot 2
color object 2,rgb(255,0,0)
ghost object on 2
make object sphere 3,0.5
color object 3,rgb(255,0,0)
ghost object on 3
position object 1,0,1.5,0
speed# = 0.5
`create world
restore world
for w = 1 to 7
read posx#,posy#,posz#,sizex#,sizey#,sizez#
make object box 10+w,sizex#,sizey#,sizez#
position object 10+w,posx#,posy#,posz#
make static object 10+w
sizex# = sizex# / 2
sizey# = sizey# / 2
sizez# = sizez# / 2
make static collision box posx#-sizex#,posy#-sizey#,posz#-sizez#,posx#+sizex#,posy#+sizey#,posz#+sizez#
delete object 10+w
next w
do
`get player data
posx# = object position x(1)
posy# = object position y(1)
posz# = object position z(1)
angy# = object angle y(1)
`controls
if upkey() = 1
posx# = newxvalue(posx#,angy#,speed#)
posz# = newzvalue(posz#,angy#,speed#)
endif
if downkey() = 1
posx# = newxvalue(posx#,angy#,speed#*-1)
posz# = newzvalue(posz#,angy#,speed#*-1)
endif
if leftkey() = 1
yrotate object 1,wrapvalue(angy# - 1)
endif
if rightkey() = 1
yrotate object 1,wrapvalue(angy# + 1)
endif
`control camera
follow_camera(1,addang#)
addang# = addang# - (mousemovex()/10)
`*** collision of player ***
oldposx# = object position x(1)
olsposy# = object position y(1)
oldposz# = object position z(1)
sx# = object size x(1)/2
sy# = object size y(1)/2
sz# = object size z(1)/2
if get static collision hit(oldposx#-sx#,oldposy#-sy#,oldposz#-sz#,oldposx#+sx#,oldposy#+sy#,oldposz#+sz#,posx#-sx#,posy#-sy#,posz#-sz#,posx#+sx#,posy#+sy#,posz#+sz#)=1
dec posx#,get static collision x()
dec posy#,get static collision y()
dec posz#,get static collision z()
endif
`*** sniper laser ***
tx# = newxvalue(posx#,angy#,200)
ty# = posy#
tz# = newzvalue(posz#,angy#,200)
if static line of sight(posx#,posy#,posz#,tx#,ty#,tz#,0.001,0) > 0
tx# = static line of sight x()
ty# = static line of sight y()
tz# = static line of sight z()
endif
`raycast
`get distance
distance# = sqrt( (tx# - posx#)^2 + (ty# - posy#)^2 + (tz#-posz#)^2)
scale object 2,10,10,distance#*100
rayx# = newxvalue(posx#,angy#,distance#/2)
rayy# = posy#
rayz# = newzvalue(posz#,angy#,distance#/2)
position object 2,rayx#,rayy#,rayz#
point object 2,posx#,posy#,posz#
position object 3,tx#,ty#,tz#
`update player
position object 1,posx#,posy#,posz#
sync
loop
`*********
`functions
`*********
function follow_camera(id,addang#)
dist# = 10.0
height# = 7.5
`store id's position and angle
posx#=object position x(id)
posy#=object position y(id)
posz#=object position z(id)
angley#=wrapvalue(object angle y(id)-180 + addang#)
`calculate camera's position
camx#=newxvalue(posx#,angley#,dist#)
camz#=newzvalue(posz#,angley#,dist#)
camy#=posy# + height#
camx#=curvevalue(camx#,camera position x(),15)
camy#=curvevalue(camy#,camera position y(),15)
camz#=curvevalue(camz#,camera position z(),15)
`update camera
position camera camx#,camy#,camz#
point camera posx#,posy# + (height#/2),posz#
endfunction
`****
`DATA
`****
world:
data 50.0,15.0,0.0,2.0,30.0,100.0
data 0.0,15.0,50.0,100.0,30.0,2.0
data -50.0,15.0,0.0,2.0,30.0,100.0
data 0.0,15.0,-50.0,100.0,30.0,2.0
data 25.0,5.0,18.0,2.0,10.0,6.0
data -20.0,2.0,-36.0,3.0,4.0,5.0
data 11.0,5.0,-16.0,5.0,10.0,5.0
Immunity and Annihalation makes Immunihalation...