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. |
| ||
Well, you didn't show whether you're actually using the Collisions command or not... the player sinks to a certain point into the level mesh Which may be due to you not having the pivot in the correct spot... I can't tell from what you've shown. If the player mesh falls to a certain point and then stops, most likely your collisions are working.Actually your question is confusing (which is why I don't think you received many responses). You have two seperate issues. Don't put them both in the same post, because I find it hard to figure out what pertains to what. Also, stating things like "Movement is also not working." doesn't really tell me anything. HOW is it not working? What do you expect it to do that it doesn't do? Oh, and by the way, what does any of this have to do with quicksand? |
| ||
Wol, I'm not going to write a heavily detailed description aside from the source. If I'm making a first-person game, it's somewhat obvious what I wish to achieve (unless I was doing something like Sacrafice or other non-standard FPS titles). And how does this relate to quicksand? Use your head; if you step in quicksand, you sink (or the world lies about things like that and you don't sink). By "Movement is also not working" I mean I setup movement mechanics and they don't respond whatsoever. I have the Collision command stating that the player collides with the level: Collisions(typePlayer,typeLevel,3,1) There it's set to elipsoid-to-box collisions and I've tried the other two modes and still the player sinks, which I'm confused about. And as for the RenderWorld bit, if you actually read the first post (besides the code) then you would see I have stated what I wish to achieve. Read posts and think before you reply in a condescending manner when you aren't sure what the question is. Especially when it's plainly stated. |
| ||
Oh! I think I understand you now. You don't want to know how to create a quicksand effect. You are EXPERIENCING a quicksand effect. Sorry for not understanding that. Read posts and think before you reply in a condescending manner when you aren't sure what the question is. Especially when it's plainly stated. Diddo...I was being honest, not condescending. I actually didn't understand what you wanted to acheive. if you actually read the first post I did, multiple times.When you wrote: I'm not asking how you do a sort of 'quicksand pit' as I'm already looking at one. I thought you were saying that you created one on purpose.I think my first statement still stands. Are you sure that your lower pivot is placed in the correct spot? If the player mesh falls to a certain point and then stops, most likely your collisions are working. |