Hi hlcoders,
in a project a friend is working on together we want the different gravity
directions for different objects in the game and further, we want that
direction to be able to change depending on the mechanics of the game.
I found that changing the gravity is not as simple as it seen. First of all, it
seems to be applied differently for players and other entities. I started with
players though because that's the most important, other entities can be
implemented later.
I found CGameMovement::AddGravity/StartGravity/FinnishGravity and changed for
example
mv->m_vecVelocity[2] -= (ent_gravity * sv_gravity.GetFloat() * 0.5 *
gpGlobals->frametime );
into
mv->m_vecVelocity.MulAdd(mv->m_vecVelocity, player->m_vecGravity, ent_gravity *
sv_gravity.GetFloat() * 0.5 * gpGlobals->frametime);
I'll probably have to move mVecGravity somewhere else later, so far I'm just
trying this to see if I can make it work. First I tried with a gravity =
(1,0,0) and it worked fine apart from the fact that walkable floor is still
always in negative z-direction. That's something I have to change in other
parts of the code, possibly CategorizePosition or something but that's a later
problem because I found another thing.
If I try a gravity = (0,0,1) (positive z-direction) it did Not work, at least I
wasn't falling upwards. I think somehow the z-velocity is simply zero:ed if the
game thinks you're standing on walkable floor as seen in
CGameMovement::FullWalkMove
// If we are on ground, no downward velocity.
if ( player->GetGroundEntity() != NULL )
{
mv->m_vecVelocity[2] = 0;
}
I tried temporarily commenting this out, and some other similar snippets in
that method but still I wasn't falling upwards. I'm thinking the same trick is
being performed somewhere else in the code but it suspect I will spend a whole
lot time searching for it. I'll throw the debugger at it probably but I'm
unfortunately not super skilled in debuggers and I'm kind of scared it will
blow up on me with execution jumping back and forth between engine code and sdk
code.
So I ask you for input, why do you think a positive gravity direction isn't
working? Where do you think I should start looking.
Thank you for your time, hlcoders. I'm obviously new here. Oh, I forgot to say
that this is the scrath sdk... because I never got hl2, all I have is l4d.
/Elias 'Locke' Wulcan
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders