I'm coding a 3d platform game, but I had some troubles dealing with blitz collisions.
If using blitz standard collisions:
1)I want the player to reach the peak of the slope without any effort, and I want the player to move freely in any direction without being 'adjusted' by the gravity/collision force.
2)When the player goes down on the slope, sometimes it does not collide perfectly with it.
3)When the player is near an edge of the platform it slides down slowly(due to the ellipsoid collision shape)
With linepick function I had less problems but:
1)The player is able to jump on the platform even from below it
I need a good solution :(
If using blitz standard collisions:
1)I want the player to reach the peak of the slope without any effort, and I want the player to move freely in any direction without being 'adjusted' by the gravity/collision force.
2)When the player goes down on the slope, sometimes it does not collide perfectly with it.
3)When the player is near an edge of the platform it slides down slowly(due to the ellipsoid collision shape)
With linepick function I had less problems but:
1)The player is able to jump on the platform even from below it
I need a good solution :(
Graphics3D 800,600,32,2 Global cam=CreateCamera() RotateEntity cam,20,0,0 PositionEntity cam,0,10,-14 light=CreateLight(2) PositionEntity light,0,4000,-700 Type char Field mesh Field name$ Field pxDummy Field curdir_x# Field curdir_y# Field curdir_z# Field wanteddir_vx# Field wanteddir_vz# Field curPosY# Field moveSpeed# Field groundCollision End Type Const collType_Char=1 Const collType_Ground=2 Const collType_Platform=3 ;----------------------------------------------------- Global ch.char=New char ch\moveSpeed#=0.08 ch\pxDummy=CreateCube() EntityType ch\pxDummy,collType_Char EntityRadius ch\pxDummy,1,2 EntityColor ch\pxDummy,255,0,0 ScaleEntity ch\pxDummy,1,2,1 d=CreateCone() ScaleMesh d,.5,.5,.5 RotateMesh d,-90,0,0 PositionMesh d,0,0,-2 AddMesh d,ch\pxDummy PositionEntity ch\pxDummy,0,4,0 ch\curPosY=4 FreeEntity d Global Ground=CreateCube() EntityType Ground,collType_Ground ScaleMesh Ground,20,1,20 slope=CreateCube() ScaleMesh slope,10,10,10 RotateMesh slope,0,0,30 PositionMesh slope,-12,-4,0 AddMesh slope,Ground FreeEntity slope EntityPickMode Ground,2 plt=CreateCube() ScaleMesh plt,4,.5,4 PositionMesh plt,7,6,0 EntityType plt,collType_Platform EntityPickMode plt,2 ;----------------------------------------------------- Global collMethod=1 ;1>Blitz Collisions, 2>Ground LinePick ;----------------------------------------------------- If collMethod=1 Then Collisions collType_Char,collType_Ground,2,3 Collisions collType_Char,collType_Platform,2,2 EndIf timer=CreateTimer(60) Repeat WaitTimer(timer) ch\groundCollision=False ch\wanteddir_vx=0:ch\wanteddir_vz=0 If KeyDown(205) Then ch\wanteddir_vx=1 If KeyDown(203) Then ch\wanteddir_vx=-1 If KeyDown(200) Then ch\wanteddir_vz=1 If KeyDown(208) Then ch\wanteddir_vz=-1 TFormNormal ch\wanteddir_vx,0,ch\wanteddir_vz,0,0 ch\wanteddir_vx=TFormedX() ch\wanteddir_vz=TFormedZ() If ch\wanteddir_vx<>0 Or ch\wanteddir_vz<>0 Then AlignToVector ch\pxDummy,-ch\wanteddir_vz,0,ch\wanteddir_vx,1,1 TranslateEntity ch\pxDummy,((ch\wanteddir_vx)*ch\moveSpeed#),0,((ch\wanteddir_vz)*ch\moveSpeed#) EndIf If collMethod=2 Then ;Line GroundPick pick_length#=2.1 If LinePick(EntityX#(ch\pxDummy), EntityY#(ch\pxDummy), EntityZ#(ch\pxDummy), 0, -pick_length, 0) > 0 ch\groundCollision=True PositionEntity ch\pxDummy,EntityX#(ch\pxDummy,True),PickedY()+2,EntityZ(ch\pxDummy,True),True EndIf EndIf ;GRAVITY ----------------------------------- ty#=EntityY(ch\pxDummy) y_vel#=(ty-ch\curPosY) ch\curPosY=ty If KeyHit(57) ;jump y_vel=1.1 Else y_vel=y_vel-.1 ;2 EndIf TranslateEntity ch\pxDummy,0,y_vel,0 If CountCollisions( ch\pxDummy ) If EntityCollided( ch\pxDummy,collType_Ground ) Or EntityCollided( ch\pxDummy,collType_Platform ) ch\groundCollision=True EndIf EndIf UpdateWorld RenderWorld Text (610-FontWidth()),FontHeight()*tc,"Ground Collision: "+ch\groundCollision Flip (False) Until KeyHit(1) End