I thought that the program must be checking for a collision in order for the collision to work? That's why I put the code in the main loop so it continuously checks for the collision.
I've simplified my program to the basics, removing all the textures and stuff so there would be less code and it would be easier to analyze. But I still cant figure out what I'm doing wrong.
This is my whole program
sync on
sync rate 30
autocam off
hide mouse
randomize timer()
Make Light 29
Set Light Range 29, 5000
Position Light 29, 0,400,0
Point Light 29, 0,0,0
REM make player
make object cone 1,100
color object 1,rgb(10,55,200)
position object 1, 0,100,0
scale object 1, 60,130,35
REM floor
make object plain 6, 3000,3000,10
position object 6, 0,0,0
rotate object 6, 90,0,0
color object 6,rgb(255,0,0)
REM make Trees
for tree = 100 to 150
rndx= -1500 +rnd(3000)
rndz= -1500 +rnd(3000)
make object cylinder tree,10
position object tree, rndx,150,rndz
scale object tree, 500,3000,500
color object tree, rgb(0,0,0)
leaf=tree+51
make object sphere leaf,10
position object leaf, rndx,270,rndz
scale object leaf, 2000,1400,2000
color object leaf ,rgb(0,255,0)
next tree
REM camera
cpx#=camera position x()
cpy#=camera position y()
cpz#=camera position z()
cax#=camera angle x()
cay#=camera angle y()
caz#=camera angle z()
set camera range 10,10000
` MAIN SECTION LOOP
do
REM COLLISIONS
set object collision on 1
make object collision box 1,-50,-50,-50,50,50,50,0
REM tree collisions where x=object id of the trees **********
for x = 100 to 150
set object collision on x
make object collision box x,-50,-50,-50,50,50,50,0
next x
REM player position
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
A1X = object angle X(1)
A1Y = object angle Y(1)
A1Z = object angle Z(1)
center text 320,440,"USE ARROW KEYS TO MOVE"
`CONTROL INPUT
if Upkey()=1 then move object 1,10
if Downkey()=1 then move object 1,-10
if Leftkey()=1 then Yrotate object 1,wrapvalue(A1Y-5)
if Rightkey()=1 then Yrotate object 1,wrapvalue(A1Y+5)
`MOVE CAMERA
position camera CPX#, P1Y#+65, CPZ#
point camera P1X#, P1Y#+35, P1Z#
CPZ#=newzvalue(P1Z#, A1Y-180, 400)
CPX#=newxvalue(P1X#, A1Y-180, 400)
sync
loop
I'm trying to get my character to crash into the trees but it just goes through them.