I am making a game in Blitz3d and I made simple gravity, however once the object falls on the ground, it goes through it very slowly. The ground is a plane and I have collision on it.
This is a pretty old engine, and not a lot of people are using it but I decided to use it because it's easier than Unity3D for me and it's very basic and customizable.
Here's my code:
AppTitle "FPS" Graphics3D 800,600,32,2 SetBuffer BackBuffer() SeedRnd MilliSecs() HidePointer ;Objects Global player = CreatePivot() Global camera = CreateCamera(player) Global cube = CreateCube() Global light = CreateLight() Global plane = CreatePlane() Global cube2 = CreateCube(player) col_plane = 1 col_player = 2 col_cube = 3 ;Vars gravity# = -.00001 plx# = 0 ply# = 0 plz# = 0 pldx# = 0 pldy# = 0 pldz# = 0 ;Textures CameraClsColor camera,135,206,250 box = LoadTexture("models\box.png") dirt = LoadTexture("models\dirt.jpg") ;Object Details EntityType cube,col_cube EntityType player,col_player EntityType plane,col_plane EntityRadius player,1.2 EntityRadius plane,1 PositionEntity player,0,10,5 PositionEntity cube,0,1,5 PositionEntity light,0,2,0 PositionEntity plane,0,0,0 EntityTexture cube,box EntityTexture plane,dirt ScaleTexture dirt,5,5 CameraRange camera,0.25,200 ;Called Functions While Not KeyHit(1) Cls ;Collisions Collisions col_player,col_plane,2,2 Collisions col_player,col_cube,2,2 If ply < -2 Then ply = 0 pldy = -pldy*.39 EndIf If ply < -1.8 Then pldx = .6*pldx pldz = .6*pldz If KeyDown(57) Then pldy = 2 EndIf pldy = pldy + gravity plx = plx + pldx ply = ply + pldy plz = plz + pldz PositionEntity player,EntityX(player)+plx,EntityY(player)+ply,EntityZ(player)+plz control() RenderWorld() UpdateWorld() MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 Flip Wend End ;Functions Function control() If KeyDown(42) ;Shift (for running) If KeyDown(17) And KeyDown(30) ;W and A MoveEntity player,-0.15,0,0.15 ElseIf KeyDown(17) And KeyDown(32) ;W and D MoveEntity player,0.15,0,0.15 ElseIf KeyDown(17) And KeyDown(30) ;S and A MoveEntity player,-0.15,0,-0.15 ElseIf KeyDown(17) And KeyDown(32) ;S and D MoveEntity player,0.15,0,-0.15 ElseIf KeyDown(17) ;W MoveEntity player,0,0,0.15 ElseIf KeyDown(31) ;S MoveEntity player,0,0,-0.15 ElseIf KeyDown(30) ;A MoveEntity player,-0.15,0,0 ElseIf KeyDown(32) ;D MoveEntity player,0.15,0,0 End If Else ;Walking If KeyDown(17) And KeyDown(30) ;W and A MoveEntity player,-0.1,0,0.1 ElseIf KeyDown(17) And KeyDown(32) ;W and D MoveEntity player,0.1,0,0.1 ElseIf KeyDown(17) And KeyDown(30) ;S and A MoveEntity player,-0.1,0,-0.1 ElseIf KeyDown(17) And KeyDown(32) ;S and D MoveEntity player,0.1,0,-0.1 ElseIf KeyDown(17) ;W MoveEntity player,0,0,0.1 ElseIf KeyDown(31) ;S MoveEntity player,0,0,-0.1 ElseIf KeyDown(30) ;A MoveEntity player,-0.1,0,0 ElseIf KeyDown(32) ;D MoveEntity player,0.1,0,0 End If End If While KeyDown(16) ;Q RotateEntity camera,MouseXSpeed(),10,10 Wend While KeyDown(18) ;E RotateEntity camera,0,-10,-10 Wend TurnEntity player, 0, -MouseXSpeed()/6.0, 0 TurnEntity camera, MouseYSpeed()/6.0, 0, 0 If EntityPitch(camera) < -70 RotateEntity camera, -70, EntityYaw(camera), EntityRoll(camera) ElseIf EntityPitch(camera) > 70 RotateEntity camera, 70, EntityYaw(camera), EntityRoll(camera) EndIf End Function If there's some one who can actually help me with this, I would appreciate it.