Fixing trigger gravity
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
This article needs more links to other articles to help integrate it into the encyclopedia. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024
January 2024
This article is an orphan, meaning that few or no articles link to it.
You can help by adding links to this article from other relevant articles.
January 2024
You can help by adding links to this article from other relevant articles.
January 2024
Warning:This fix doesn't appear to work 100% of the time, use at your own risk.
Currently the trigger_gravity brush entity doesn't actually function properly.
To fix gravity triggers, navigate to triggers.cpp, around line 2651 you should find this:
class CTriggerGravity : public CBaseTrigger
{
public:
DECLARE_CLASS( CTriggerGravity, CBaseTrigger );
DECLARE_DATADESC();
void Spawn( void );
void GravityTouch( CBaseEntity *pOther );
};
LINK_ENTITY_TO_CLASS( trigger_gravity, CTriggerGravity );
BEGIN_DATADESC( CTriggerGravity )
// Function Pointers
DEFINE_FUNCTION(GravityTouch),
END_DATADESC()
void CTriggerGravity::Spawn( void )
{
BaseClass::Spawn();
InitTrigger();
SetTouch( &CTriggerGravity::GravityTouch );
}
void CTriggerGravity::GravityTouch( CBaseEntity *pOther )
{
// Only save on clients
if ( !pOther->IsPlayer() )
return;
pOther->SetGravity( GetGravity() );
}
replace the whole class, functions and all with this:
class CTriggerGravity : public CTriggerMultiple
{
public:
DECLARE_CLASS(CTriggerGravity, CTriggerMultiple);
DECLARE_DATADESC();
void Spawn( void );
void StartTouch(CBaseEntity *pOther);
void EndTouch(CBaseEntity *pOther);
};
LINK_ENTITY_TO_CLASS( trigger_gravity, CTriggerGravity );
BEGIN_DATADESC( CTriggerGravity )
// Function Pointers
DEFINE_FUNCTION(StartTouch),
DEFINE_FUNCTION(EndTouch),
END_DATADESC()
void CTriggerGravity::Spawn( void )
{
BaseClass::Spawn();
InitTrigger();
//SetTouch( &CTriggerGravity::GravityTouch );
}
void CTriggerGravity::StartTouch( CBaseEntity *pOther )
{
// Only save on clients
//if ( !pOther->IsPlayer() )
// return;
pOther->SetGravity( GetGravity() );
}
void CTriggerGravity::EndTouch(CBaseEntity *pOther)
{
// Only save on clients
//if ( !pOther->IsPlayer() )
// return;
pOther->SetGravity(1);
}
trigger_gravity should work fine now on players, but still won't change a physics object's gravity.