CBaseEntity Functions: Difference between revisions
Jump to navigation
Jump to search
Note:In fact,
Charlysotelo (talk | contribs) (Created page with "== GetAbsOrigin() == <code>GetAbsOrigin()</code> returns the absolute (i.e. world-relative) origin of an entity as a vector. Its sister function '''<code>SetAbsOrigi...") |
Charlysotelo (talk | contribs) No edit summary |
||
Line 14: | Line 14: | ||
Msg( "My World Position Is %f %f %f.\n",GetAbsOrigin().x,GetAbsOrigin().y,GetAbsOrigin().z); | Msg( "My World Position Is %f %f %f.\n",GetAbsOrigin().x,GetAbsOrigin().y,GetAbsOrigin().z); | ||
} | |||
</source> | |||
== GetAbsAngles() == | |||
<code>GetAbsAngles()</code> returns the absolute (i.e. [[world]]-relative) [[angles]] of an entity as a [[QAngle]]. Its sister function '''<code>SetAbsAngles()</code>''' changes it. | |||
Example Usage: | |||
<source lang=cpp> | |||
void CMyEntity::Think() | |||
{ | |||
BaseClass::Think(); // Always do this if you override Think() | |||
Msg( "My World Angle Is %f %f %f.\n",GetAbsAngles().x,GetAbsAngles().y,GetAbsAngles().z); | |||
} | } | ||
</source> | </source> |
Revision as of 02:03, 6 July 2014
GetAbsOrigin()
GetAbsOrigin()
returns the absolute (i.e. world-relative) origin of an entity as a vector. Its sister function SetAbsOrigin()
changes it.
The origin is actually stored in local space (i.e parent-relative), meaning that the Abs functions perform extra calculations to get their return value. Use the more direct GetLocalOrigin()
and SetLocalOrigin()
if possible; they work directly with the stored value (m_vecOrigin
).

GetAbsOrigin()
seems to recalculate its return value only if it was changed since the last time it was used, otherwise it just returns cached value stored in a member variable.Example Usage:
void CMyEntity::Think()
{
BaseClass::Think(); // Always do this if you override Think()
Msg( "My World Position Is %f %f %f.\n",GetAbsOrigin().x,GetAbsOrigin().y,GetAbsOrigin().z);
}
GetAbsAngles()
GetAbsAngles()
returns the absolute (i.e. world-relative) angles of an entity as a QAngle. Its sister function SetAbsAngles()
changes it.
Example Usage:
void CMyEntity::Think()
{
BaseClass::Think(); // Always do this if you override Think()
Msg( "My World Angle Is %f %f %f.\n",GetAbsAngles().x,GetAbsAngles().y,GetAbsAngles().z);
}