collisions
Blitz3D Forums/Blitz3D Beginners Area/collisions
| ||
i need help with collisions. it won't detect them no matter what i do. here's my code Graphics3D 940,680,16,2 SetBuffer BackBuffer() Const type_cam=1,type_terrain=11,type_car=10 Collisions type_cam,type_terrain,2,3 Collisions type_cam,type_car,2,3 land=LoadTerrain("hmap_1024.bmp") ScaleEntity land,10,800,10 PositionEntity land,0,-1,10 TerrainShading land,True TerrainDetail land,1000,True EntityType land,type_terrain tex=LoadTexture( "terrain-1.jpg" ) ScaleTexture tex,10,10 EntityTexture land,tex,0,1 car=LoadMesh("car2.x") ScaleEntity car,10,10,10 PositionEntity car,0,5,2 RotateEntity car,0,180,0 EntityType car,type_car camera=CreateCamera() PositionEntity camera,50,20,-20 TurnEntity camera,0,0,0 EntityType camera,type_cams water_level=CreatePlane() EntityAlpha water_level,0.4 water=CreatePlane() PositionEntity water,Sin(time*.01)*10,water_level+Sin(time*.05)*.5,Cos(time*.02)*10 EntityAlpha water,0.4 wtex=LoadTexture("water-2_mip.bmp") ScaleTexture wtex,100,100 EntityTexture water,wtex,0,1 EntityTexture water_level,wtex,0,1 l=CreateLight() TurnEntity l,45,45,0 LightColor l,255,255,255 While Not KeyDown(1) If KeyHit(17) wire=Not wire WireFrame wire EndIf If KeyDown(200) TurnEntity camera,-2,0,0 Else If KeyDown(208) TurnEntity camera,2,0,0 EndIf If Not KeyDown(30) MoveEntity water_level,2,0,0 Else MoveEntity water_level,2,0,0 EndIf If KeyDown(203) TurnEntity camera,0,+2,0 EndIf If KeyDown(205) TurnEntity camera,0,-2,0 EndIf If KeyDown(30) MoveEntity camera,0,0,2 EndIf If KeyDown(31) MoveEntity camera,0,0,10 EndIf If KeyDown(32) MoveEntity camera,0,0,30 EndIf If KeyDown(44) MoveEntity camera,0,0,-2 EndIf If KeyDown(57) MoveEntity camera,0,10,0 Else MoveEntity camera,0,-2,0 EndIf RenderWorld Flip Wend End |
| ||
hey! First thing i see is that you have no UpdateWorld command. Put this before your RenderWorld. Second thing is this:camera=CreateCamera() PositionEntity camera,50,20,-20 TurnEntity camera,0,0,0 EntityType camera,type_cams you have no variable called type_cams. Spelling mistake there :) should be camera=CreateCamera() PositionEntity camera,50,20,-20 TurnEntity camera,0,0,0 EntityType camera,type_cam so it should look like this when changed Graphics3D 940,680,16,2 SetBuffer BackBuffer() Const type_cam=1,type_terrain=11,type_car=10 Collisions type_cam,type_terrain,2,3 Collisions type_cam,type_car,2,3 land=LoadTerrain("hmap_1024.bmp") ScaleEntity land,10,800,10 PositionEntity land,0,-1,10 TerrainShading land,True TerrainDetail land,1000,True EntityType land,type_terrain tex=LoadTexture( "terrain-1.jpg" ) ScaleTexture tex,10,10 EntityTexture land,tex,0,1 car=LoadMesh("car2.x") ScaleEntity car,10,10,10 PositionEntity car,0,5,2 RotateEntity car,0,180,0 EntityType car,type_car camera=CreateCamera() PositionEntity camera,50,20,-20 TurnEntity camera,0,0,0 EntityType camera,type_cam water_level=CreatePlane() EntityAlpha water_level,0.4 water=CreatePlane() PositionEntity water,Sin(time*.01)*10,water_level+Sin(time*.05)*.5,Cos(time*.02)*10 EntityAlpha water,0.4 wtex=LoadTexture("water-2_mip.bmp") ScaleTexture wtex,100,100 EntityTexture water,wtex,0,1 EntityTexture water_level,wtex,0,1 l=CreateLight() TurnEntity l,45,45,0 LightColor l,255,255,255 While Not KeyDown(1) If KeyHit(17) wire=Not wire WireFrame wire EndIf If KeyDown(200) TurnEntity camera,-2,0,0 Else If KeyDown(208) TurnEntity camera,2,0,0 EndIf If Not KeyDown(30) MoveEntity water_level,2,0,0 Else MoveEntity water_level,2,0,0 EndIf If KeyDown(203) TurnEntity camera,0,+2,0 EndIf If KeyDown(205) TurnEntity camera,0,-2,0 EndIf If KeyDown(30) MoveEntity camera,0,0,2 EndIf If KeyDown(31) MoveEntity camera,0,0,10 EndIf If KeyDown(32) MoveEntity camera,0,0,30 EndIf If KeyDown(44) MoveEntity camera,0,0,-2 EndIf If KeyDown(57) MoveEntity camera,0,10,0 Else MoveEntity camera,0,-2,0 EndIf UpdateWorld RenderWorld Flip Wend End I've put in some indentation. You should really do that with your code, as it makes it look cleaner and easier to follow thru should you look back on it or have an error :) Looking good tho, keep up the good work! |
| ||
thanks! -me |