I think this is the same bug. Box to polygon collision is off by half the objects (box collision object) size when moving in the +X direction (tested with different size cubes and complex levels all the same result) Here is code showing it. Arrow keys move around. Press any mouse button for close up of collision.
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object cube 1, 100
set object collision to polygons 1
color object 1, rgb(255,0,0)
cam_obj = 2
obj_size = 32
make object cube cam_obj, obj_size
set object collision to boxes 2
position object cam_obj, 0, 25, -75
direct = 1
do
`movement
if upkey()=1 then yrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 1
if downkey()=1 then yrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then yrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then yrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 200, 0
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y# + (object size x(cam_obj)*2), cam_pos_z#
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# + 100) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# - 100) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop
Seems to be perfect in the other 3 directions.
And Sphere to polygon collision is off by half the objects (sphere collision object) size when moving in the +X direction and 18.75% off in the +Z direction (tested with different size cubes and complex levels all the same result) Here is code showing it. Arrow keys move around. Press any mouse button for close up of collision.
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object cube 1, 100
set object collision to polygons 1
color object 1, rgb(255,0,0)
cam_obj = 2
obj_size = 32
make object sphere cam_obj, obj_size
set object collision to spheres 2
position object cam_obj, 0, 25, -75
direct = 1
do
`movement
if upkey()=1 then yrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 1
if downkey()=1 then yrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then yrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then yrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 200, 0
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y# + (object size x(cam_obj)*2), cam_pos_z#
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# + 100) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# - 100) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop
The other 2 directions seem dead on. Also with Sphere to polygon and Boxes to polygon, when the object is halfway through the poly it shows no collision in all directions. You can use those same codes to see it.
[edit] The y axis has the exact same errors as x with box to polygon and sphere to polygon.
Sphere to polygon
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object cube 1, 100
set object collision to polygons 1
color object 1, rgb(255,0,0)
cam_obj = 2
obj_size = 32
make object sphere cam_obj, obj_size
set object collision to spheres 2
position object cam_obj, -75, 25, 0
point object cam_obj,0,0,0
direct = 1
do
`movement
if upkey()=1 then xrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 1
if downkey()=1 then xrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then xrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then xrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 0, 200
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y#, cam_pos_z# + (object size x(cam_obj)*2)
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y# + 100, cam_pos_z#) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y# - 100, cam_pos_z#) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop
Box to polygon
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object cube 1, 100
set object collision to polygons 1
color object 1, rgb(0,255,0)
cam_obj = 2
obj_size = 32
make object cube cam_obj, obj_size
set object collision to boxes 2
position object cam_obj, -75, 25, 0
point object cam_obj,0,0,0
color object cam_obj, rgb(255,0,0)
direct = 1
do
`movement
if upkey()=1 then xrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 1
if downkey()=1 then xrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then xrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then xrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 0, 200
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y#, cam_pos_z# + (object size x(cam_obj)*2)
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y# + 100, cam_pos_z#) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y# - 100, cam_pos_z#) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop
[edit2] Sphere to sphere collision is really close in all 3 axi.
[edit3] Just found another error. This is a very serious bug. If you can't get the collision checking working right at least get it so it gives ar error message or doesn't crash. For some reason complex polygon objects touching (like loading a level broken into several objects) when you call collision checking commands on them crashes the program. It took me a while to replicate this one as it works on most of my levels but not all. Here is a code showing it working (with cube objects) and in the next code it crashes (with spheres). comment out the 2 lines calling the object collision() commands and it no longer crashes. Another reason it was hard to find as I don't always check my level objects for collision (usually just movable objects).
Working code but the collision on the x-, x+, y-, and y+ directions is half the objects width off @ center to center collision (coners are very dodgy).,
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object cube 1, 32
set object collision to polygons 1
color object 1, rgb(255,0,0)
cam_obj = 2
obj_size = 32
make object cube cam_obj, obj_size
set object collision to polygons 2
position object cam_obj, 50, 0, 0
direct = 1
do
`movement
if upkey()=1 then yrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 1
if downkey()=1 then yrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then yrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then yrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 200, 0
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y# + (object size x(cam_obj)*2), cam_pos_z#
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# + 100) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# - 100) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop
Crashing code as soon as the spheres touch it crashes,
`Main Source File
sync on : sync rate 100
autocam off : hide mouse
make object sphere 1, 32
set object collision to polygons 1
color object 1, rgb(255,0,0)
cam_obj = 2
obj_size = 32
make object sphere cam_obj, obj_size
set object collision to polygons 2
position object cam_obj, 50, 0, 0
direct = 1
do
`movement
if upkey()=1 then yrotate object cam_obj, 0 : move object cam_obj,.1 : direct = 1
if downkey()=1 then yrotate object cam_obj, 180 : move object cam_obj,.1 : direct = 3
if leftkey()=1 then yrotate object cam_obj, 270 : move object cam_obj,.1 : direct = 4
if rightkey()=1 then yrotate object cam_obj, 90 : move object cam_obj,.1 : direct = 2
cam_pos_x# = object position x(cam_obj)
cam_pos_y# = object position y(cam_obj)
cam_pos_z# = object position z(cam_obj)
`Click any mouse button for closeup view
if mouseclick() = 0
position camera 0, 200, 0
point camera 0, 0, 0
else
position camera cam_pos_x#, cam_pos_y# + (object size x(cam_obj)*2), cam_pos_z#
point camera cam_pos_x#, cam_pos_y#, cam_pos_z#
endif
set cursor 5,5
print "Object colliding with Object 2 = ",object collision(2,0)
set cursor 5,20
print "Object colliding with Object 1 = ",object collision(1,0)
select direct
case 1 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# + 100) - (obj_size/2)) : endcase
case 2 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# + 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
case 3 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x#, cam_pos_y#, cam_pos_z# - 100) - (obj_size/2)) : endcase
case 4 : c# = (intersect object(1,cam_pos_x#, cam_pos_y#, cam_pos_z#,cam_pos_x# - 100, cam_pos_y#, cam_pos_z#) - (obj_size/2)) : endcase
endselect
set cursor 5,35
print "Distance to object in direction moving (edge to edge) = ", c#
sync
loop