you will need the 4 DOWN direction INTERSECT OBJECT() checks.
how do I position the down direction intersect objects then?
and yeah I want so the tiniest bit is on the box will stay on.
(I think i solved the first one)
My code so far:
sync on
sync rate 60
set global collision on
backdrop on
autocam off
make object cube 1,20
position object 1,0,20,0
color object 1,RGB(255,255,60)
make object cube 2,20
position object 2,0,0,0
make object cube 3,20
position object 3,20,0,0
make object cube 4,20
position object 4,40,0,0
make object cube 5,20
position object 5,60,0,0
make object cube 6,20
position object 6,60,20,0
make object cube 7,20
position object 7,80,40,0
make object cube 8,20
position object 8,80,60,20
make object cube 9,20
position object 9,80,60,-20
make camera 1
Do
move object down 1,Falling#
inc Falling#,0.1
x=object position x(1)
y=object position y(1)
z=object position z(1)
for b=2 to 9
D#=INTERSECT OBJECT(b,x,y,z,x,y-10.0,z) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x,y+(10.0-D#),z
Falling#=0
Endif
D#=INTERSECT OBJECT(b,x,y,z,x,y+10.0,z) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x,y-(10.0-D#),z
Endif
D#=INTERSECT OBJECT(b,x,y,z,x,y,z-10.0) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x,y,z+(10.0-D#)
Endif
D#=INTERSECT OBJECT(b,x,y,z,x,y,z+10.0) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x,y,z-(10.0-D#)
Endif
D#=INTERSECT OBJECT(b,x,y,z,x+10.0,y,z) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x-(10.0-D#),y,z
Endif
D#=INTERSECT OBJECT(b,x,y,z,x-10.0,y,z) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x+(10.0-D#),y,z
Endif
Next b
position camera 1,OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)-40
rotate camera 1,0,0,0
x=object position x(1)
y=object position y(1)
z=object position z(1)
if upkey()=1 then position object 1,x,y,z+1
if downkey()=1 then position object 1,x,y,z-1
if rightkey()=1 then position object 1,x+1,y,z
if leftkey()=1 then position object 1,x-1,y,z
if spacekey()=1 and Falling#=0.0
move object up 1,1
Falling#=-3.0
endif
x2=object position x(1)
y2=object position y(1)
z2=object position z(1)
for b=2 to 9
D#=INTERSECT OBJECT(b,x2,y2,z2,x2-10.0,y2,z2) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2+(10.0-D#),y2,z2
Endif
D#=INTERSECT OBJECT(b,x2,y2,z2,x2+10.0,y2,z2) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2-(10.0-D#),y2,z2
Endif
D#=INTERSECT OBJECT(b,x2,y2,z2,x2,y2-10.0,z2) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2,y2+(10.0-D#),z2
Endif
D#=INTERSECT OBJECT(b,x2,y2,z2,x2,y2+10.0,z2) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2,y2-(10.0-D#),z2
Endif
D#=INTERSECT OBJECT(b,x2,y2,z2,x2,y2,z2-10.0) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2,y2,z2+(10.0-D#)
Endif
D#=INTERSECT OBJECT(b,x2,y2,z2,x2,y2,z2+10.0) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<10.0 and D#>0.0
position object 1,x2,y2,z2-(10.0-D#)
Endif
Next b
sync
loop
I want coke, not Pepsi!