Collisions - Do I Have This Right?
Blitz3D Forums/Blitz3D Programming/Collisions - Do I Have This Right?
| ||
1- you set up a collision type (numeric or a numeric variable) 2- you entitytype an entity to a particular collision number or numeric var 3- you define the box or sphere 4- you enable collisions, source, dest, type, action 5-everything works as it should... well, i can't seem to get a collision indication between two objects... do i have the concept right? any unknowns that i should be aware of... thx --Mike |
| ||
Do you have an updateworld() in the main loop?! |
| ||
yes... actually, i think there may be 2... would that cause a problem? --Mike |
| ||
Yep, i think that would. |
| ||
It all depends on if you check for collisions after the first update world AND the second one. And it depends where abouts your movement code is etc. |
| ||
thx guys... i checked through about 7 source libs and there's only one updateworld being called... but i may not be doing the checking after the updateworld call... looking at it now... big thx... --Mike |
| ||
Are both objects in motion? You can only trust sphere to sphere if that is the case. |
| ||
one is only rotating about the x axis (a floating object) at the moment, but yes, they could both be moving during the game... --Mike |
| ||
Objects rotating don't register collisions i don't think. Don't hold me to that though :o) |
| ||
i'm also wondering if since the source object is a child of another, whether that is having an effect... still working at it... thx guys for the input... --Mike |
| ||
You might like to do some separate tests, then, just to see what does and does not work with the in-built collisions system. I'm pretty sure I'm right about the motion/sphere thing as I seem to remember that it's been mentioned a few times - do verify, though. |
| ||
good idea Sledge... doing that now... ok... wierd stuff... if i reposition the sub, the dive planes (the source object for the collison) separates from the body of the sub... which indicates that collisions are taking place, i've just gotta exempt the parent from the collisions checking... hhhmmmmm... i think i'm going about this the wrong way... --Mike |
| ||
Some interesting things can be done with the blitz collision system, with some tricky. The child situation def works i'm sure: http://www.blitzbasic.com/codearcs/codearcs.php?code=943 Graphics3D 640,480,16 SetBuffer BackBuffer() Const cube_col=1 Const sphere_col=2 Global light= CreateLight() Global camera=CreateCamera() PositionEntity camera,0,40,0 RotateEntity camera,90,0,0 Global sphere=CreateSphere() EntityType sphere,sphere_col Global level=CreatePivot() Dim cube(10) For loop=0 To 10 cube(loop)=CreateCube() PositionEntity cube(loop),-10,0,-10+loop*2 EntityType cube(loop),cube_col EntityParent cube(loop),level Next Collisions 1,2,2,2 Collisions 1,1,2,2 Collisions 1,3,2,2 While Not KeyHit(1) If KeyDown(30) MoveEntity level,0.1,0,0 If KeyDown(32) MoveEntity level,-0.1,0,0 If KeyDown(17) MoveEntity level,0,0,-0.1 If KeyDown(31) MoveEntity level,0,0,0.1 UpdateWorld updatecubes() ; make sure collisions doesn't push the cubes downwards or upwards RenderWorld Flip Wend End Function updatecubes() For loop=0 To 10 PositionEntity cube(loop),EntityX(cube(loop)),0,EntityZ(cube(loop)) Next End Function |
| ||
yeah... i can see this is gonna get messy... there is no way to do box to box collisions, is there? --Mike |
| ||
Not, unless you code them. With no rotation they are easy hehe. Or you can use other collision library... |
| ||
ok... not as messy as i thought it was gonna be... exempting the parent works... i just set the parent's entitytype to 0, check for collisions, then reset it back so it'll be included in the next subs check... but i'm gonna need to do a lil of what Ross's code does to reposition the child after collision... BIG THANKS for all the help... i think i've got this one nailed down... finally :) --Mike |