Hello. I am having difficulties with my character's movement/collision with the ground, and it's partly to do with the gravity.
I'm currently working on having my character walk along the ground in a 3D environment and still keeping ground level. The 3D environment is a .x file with an irregular surface, and some parts include raised pavements/sidewalks, so there are a few different types of elevated ground to tackle. Though the pavements do rise up vertically they are not terribly high - they come up to approximately the top of the player model's shoe. However some slopes are approaching something akin to a 25 degree angle.
Here is the code which handles this (it's very simple, possibly part of the problem):
------------------------------------------------------------
;Collisions
Const TYPE_PLAYER=1,TYPE_CAMERA=2,TYPE_SCENERY=3
; Player-to-scenery
Collisions TYPE_PLAYER,TYPE_SCENERY,2,3
gravity#=EntityY(hero\entity)
y_vel#=(gravity-hero\y)
hero\y=gravity
y_vel =-.2
TranslateEntity hero\entity,0,y_vel,0
------------------------------------------------------------
The first bit is outside of any looping bits of code. The third part is inside a Function "updatePlayer", and the middle part is in a "Repeat...Forever" loop.
Now it's working okay, but there's a couple of big problems I'm having so far: namely some slopes are pretty hard to move up, and the kerb on the side of the street is nearly impossible to traverse unless you run at it at certain angles. I'm guessing it's to do with the "gravity" constantly pulling it down, but I can't think of any other manner with which to keep the player on ground level yet still allow them smooth movement over these parts.
Any suggestions? Ideas? I'd be very grateful.
I'm currently working on having my character walk along the ground in a 3D environment and still keeping ground level. The 3D environment is a .x file with an irregular surface, and some parts include raised pavements/sidewalks, so there are a few different types of elevated ground to tackle. Though the pavements do rise up vertically they are not terribly high - they come up to approximately the top of the player model's shoe. However some slopes are approaching something akin to a 25 degree angle.
Here is the code which handles this (it's very simple, possibly part of the problem):
------------------------------------------------------------
;Collisions
Const TYPE_PLAYER=1,TYPE_CAMERA=2,TYPE_SCENERY=3
; Player-to-scenery
Collisions TYPE_PLAYER,TYPE_SCENERY,2,3
gravity#=EntityY(hero\entity)
y_vel#=(gravity-hero\y)
hero\y=gravity
y_vel =-.2
TranslateEntity hero\entity,0,y_vel,0
------------------------------------------------------------
The first bit is outside of any looping bits of code. The third part is inside a Function "updatePlayer", and the middle part is in a "Repeat...Forever" loop.
Now it's working okay, but there's a couple of big problems I'm having so far: namely some slopes are pretty hard to move up, and the kerb on the side of the street is nearly impossible to traverse unless you run at it at certain angles. I'm guessing it's to do with the "gravity" constantly pulling it down, but I can't think of any other manner with which to keep the player on ground level yet still allow them smooth movement over these parts.
Any suggestions? Ideas? I'd be very grateful.