I know this is an old post but im going to pull this one back out. I think this is a very important issue for FPS.
Alright, Im having the same problem JPL. I have posted about this once before and though everyone pitched in i really havent found a solition i like.
My solution was a snowman configuration similar to yours.
As below:
{H} The head
{B} The body
* The foot or contact point
(BTW the trick with using the foot/contact is to have it barely inside the body so that the outer edge of the body hits a stair and lifts the unit to the next step while the smaller footer (which is away from the wall) stays out of conact with any objects from the side such as a stair or wall. THus they can only jump when standing solidly on a step. The body works best with full sliding collisions on)
Basicly i had used code just like yours to see if the (*) has hit anything. If it is touching, then the user can jump, if not then he cant. But i added another layer of complexity.
What if the user is in a hallway and jumps and hits its head. Well, i added code for that too. Great. Now if the user hits their head they fall back down instead of continuing their jump cycle.
My problem is that i am having to keep track of if the head, body or the foot are directly up and down.
I have a function which sort of does this, but i dont like having to call a function to do effect all all of these objects, expecially since i want will eventually put htem all in a type so that they can be reused. (See my code below)
Does anyone know of a way to welding objects togeather so that they still have their own individual collisions but will move as one unit or mesh? It may save some CPU cycles.
'=============================
example code: if you want it take it. I dont like the solution on a large scale
Function PLAYER_MOVE(DIR_X,DIR_Y,DIR_Z)
If EntityCollided(ENTITY_headsphere , TYPE_ENVIRONMENT ) = 0 And DIR_Y >= 0
MoveEntity entity_bodysphere ,0, DIR_Y,0
Else
If EntityCollided(ENTITY_contactsphere , TYPE_ENVIRONMENT ) = 0 And DIR_Y < 0 Then
MoveEntity entity_bodysphere ,0, DIR_Y,0
End If
End If
MoveEntity entity_bodysphere ,DIR_X, 0 ,0
MoveEntity entity_bodysphere ,0, 0 ,DIR_Z
PositionEntity entity_headsphere , EntityX(entity_bodysphere ),EntityY(entity_bodysphere )+5 ,EntityZ(entity_bodysphere )
PositionEntity entity_hero , EntityX(entity_bodysphere ),EntityY(entity_bodysphere ) ,EntityZ(entity_bodysphere )
PositionEntity entity_camera , EntityX(entity_hero ) ,EntityY(entity_hero ) +13 ,EntityZ(entity_hero )
PositionEntity entity_contactsphere , EntityX(entity_bodysphere ),EntityY(entity_bodysphere )-3 ,EntityZ(entity_bodysphere )
End Function
Alright, Im having the same problem JPL. I have posted about this once before and though everyone pitched in i really havent found a solition i like.
My solution was a snowman configuration similar to yours.
As below:
{H} The head
{B} The body
* The foot or contact point
(BTW the trick with using the foot/contact is to have it barely inside the body so that the outer edge of the body hits a stair and lifts the unit to the next step while the smaller footer (which is away from the wall) stays out of conact with any objects from the side such as a stair or wall. THus they can only jump when standing solidly on a step. The body works best with full sliding collisions on)
Basicly i had used code just like yours to see if the (*) has hit anything. If it is touching, then the user can jump, if not then he cant. But i added another layer of complexity.
What if the user is in a hallway and jumps and hits its head. Well, i added code for that too. Great. Now if the user hits their head they fall back down instead of continuing their jump cycle.
My problem is that i am having to keep track of if the head, body or the foot are directly up and down.
I have a function which sort of does this, but i dont like having to call a function to do effect all all of these objects, expecially since i want will eventually put htem all in a type so that they can be reused. (See my code below)
Does anyone know of a way to welding objects togeather so that they still have their own individual collisions but will move as one unit or mesh? It may save some CPU cycles.
'=============================
example code: if you want it take it. I dont like the solution on a large scale
Function PLAYER_MOVE(DIR_X,DIR_Y,DIR_Z)
If EntityCollided(ENTITY_headsphere , TYPE_ENVIRONMENT ) = 0 And DIR_Y >= 0
MoveEntity entity_bodysphere ,0, DIR_Y,0
Else
If EntityCollided(ENTITY_contactsphere , TYPE_ENVIRONMENT ) = 0 And DIR_Y < 0 Then
MoveEntity entity_bodysphere ,0, DIR_Y,0
End If
End If
MoveEntity entity_bodysphere ,DIR_X, 0 ,0
MoveEntity entity_bodysphere ,0, 0 ,DIR_Z
PositionEntity entity_headsphere , EntityX(entity_bodysphere ),EntityY(entity_bodysphere )+5 ,EntityZ(entity_bodysphere )
PositionEntity entity_hero , EntityX(entity_bodysphere ),EntityY(entity_bodysphere ) ,EntityZ(entity_bodysphere )
PositionEntity entity_camera , EntityX(entity_hero ) ,EntityY(entity_hero ) +13 ,EntityZ(entity_hero )
PositionEntity entity_contactsphere , EntityX(entity_bodysphere ),EntityY(entity_bodysphere )-3 ,EntityZ(entity_bodysphere )
End Function