Quicksand Effect

Blitz3D Forums/Blitz3D Programming/Quicksand Effect

I'm working on a first-person game at the moment and I'm just getting the most basic mechanics in place before I move on. And no, I'm not asking how you do a sort of 'quicksand pit' as I'm already looking at one.

Problem is the player's collision detection for his feet isn't working right and the player sinks to a certain point into the level mesh. Movement is also not working. Here's pieces of the code to elaborate my issue:

Calling the player's fundimental entities
(I didn't include the HUD cam in this to explain "gameCamera")
gameCamera = CreateCamera()

	CameraClsMode(gameCamera,True,True)
	CameraRange(gameCamera,0.1,10000)

	playerPivot = CreatePivot()
	EntityParent(gameCamera,playerPivot)

	EntityType(playerPivot,typePlayer)
	EntityRadius(playerPivot,5,5)

	feetPivot = CreatePivot(playerPivot)
	PositionEntity(feetPivot,EntityX(playerPivot),EntityY(playerPivot)-30,EntityZ(playerPivot))
	EntityType(feetPivot,typePlayer)
	EntityRadius(feetPivot,5,5)

The camera sits at the same location as its parent pivot, while the feet pivot is moved below the camera and the main pivot to give the player height.

The gravity check
Global grav# = 0.2           ;Game's gravity

;=============================================
	; GRAVITY
	;=============================================
	If EntityCollided(feetPivot,typeLevel)
		pVelY = 0.0
	Else
		pVelY = pVelY - grav
	EndIf

	If pGrav <> 0.0 And EntityCollided(feetPivot,typeLevel) = False 
		TranslateEntity(playerPivot,0,pVelY,0)
	EndIf

The player pivot is told what direction it needs to move, and how fast, with variables for velocity.

Player movement, which also isn't working.
	;=============================================
	; DECELLERATION
	;=============================================

	If pVelX = 0.0 And pMovingX > 0.0
		pVelX = pVelX - pDescel
	ElseIf pVelX = 0.0 And pMovingX < 0.0
		pVelX = pVelX + pDescel
	Else
		pVelX = 0.0
	EndIf

	If pVelZ = 0.0 And pMovingZ > 0.0
		pVelZ = pVelZ - pDescel
	ElseIf pVelZ = 0.0 And pMovingZ < 0.0
		pVelZ = pVelZ + pDescel
	Else
		pVelZ = 0.0
	EndIf

	If pVelY = 0.0 And pMovingY > 0.0
		pVelY = pVelY - grav
	ElseIf pVelY = 0.0 And pMovingY < 0.0
		pVelY = pVelY - grav
	EndIf

	;=============================================
	; ACCELLERATION
	;=============================================

	If pVelX > pMovingX
		pMovingX = pMovingX + pAccel
	ElseIf pVelX < pMovingX
		pMovingX = pMovingX - pAccel
	EndIf

	If pVelY > pMovingY
		pMovingY = pMovingY + pAccel
	ElseIf pVelY < pMovingY
		pMovingY = pMovingY - pAccel
	EndIf

	If pVelZ > pMovingZ
		pMovingZ = pMovingZ + pAccel
	ElseIf pVelZ < pMovingY
		pMovingZ = pMovingZ - pAccel
	EndIf

	;=============================================
	; CHANGING DIRECTIONS
	;=============================================

	If pMovingX > 0.0 And pVelX < 0.0
		pMovingX = 0
	ElseIf pMovingX < 0.0 And pVelX > 0.0
		pMovingX = 0
	EndIf

	If pMovingY > 0.0 And pVelY < 0.0
		pMovingY = 0
	ElseIf pMovingY < 0.0 And pVelY > 0.0
		pMovingY = 0
	EndIf

	If pMovingZ > 0.0 And pVelZ < 0.0
		pMovingZ = 0
	ElseIf pMovingZ < 0.0 And pVelZ > 0.0
		pMovingZ = 0
	EndIf

	;=============================================
	; PLAYER MOVEMENT
	;=============================================
	PlayerLook()
	PlayerMove()


	;=============================================
	; MOVE THE ACTUAL ENTITY
	;=============================================
	TranslateEntity(playerPivot,pMovingX,pMovingY,pMovingZ)

As you can see, I'm in no way modest about the amount of variables I call. I'm more of a beginner in Blitz/Blitz3D even though I've been at it for almost a year now. Let me remind you how much being a newbie sucks.

The variables for movement...
Global pVelX# = 0.0          ;How fast player should be going forward/backward.
Global pVelY# = 0.0          ;How fast player should be going up/down.
Global pVelZ# = 0.0          ;How fast player should be going left/right.

Global pMovingX# = 0.0       ;Player's current speed on the X axis.
Global pMovingY# = 0.0		 ;Player's current speed on the Y axis.
Global pMovingZ# = 0.0		 ;Player's current speed on the Z axis.

Global pSpeedX# = 5.0        ;Run/Backstep speed
Global pSpeedY# = 5.0        ;Ascend/Descend speed (if player is free to move up or down. Otherwise, stick to gravity)
Global pSpeedZ# = 5.0        ;Strafing speed (usually same as run/backstep speed)

Global pAccel# = 0.1        ;How quickly the player will go from still to moving.
Global pDescel# = 0.1        ;How quickly the player will go from moving to being still.

The idea here is the player's pivot looks to pMoving to move, while pVel tells pMoving how fast it needs to accellerate to. pSpeed is how the player will move when called to do so and pAccel/pDecel dictates how fast accelleration and decelleration is.

I'm in between a mesh and a hard place at the moment, so any help is greatly appreciated.