Quote:
Originally Posted by RockTheStreet
Let's go from the other side.
Is there a function to check whether the player is touching the entity or not? So that the condition can check whether the player is in contact with the entity or not.
|
If you want to check if a certain player is not colliding with an entity simply check the player size if it is colliding with entity size...
You can do it in player prethink
PHP Code:
............
static Float:fOrigin1[3], Float:fOrigin2[3], Float:fMaxs1[3], Float:fMins1[3], Float:fMaxs2[3], Float:fMins2[3];
pev(id, pev_origin, fOrigin1);
pev(id, pev_maxs, fMaxs1);
pev(id, pev_mins, fMins1);
xs_vec_add(fMaxs1, fOrigin1, fMaxs1);
xs_vec_add(fMins1, fOrigin1, fMins1);
pev(g_entity, pev_origin, fOrigin2);
pev(g_entity, pev_maxs, fMaxs2);
pev(g_entity, pev_mins, fMins2);
xs_vec_add(fMaxs2, fOrigin2, fMaxs2);
xs_vec_add(fMins2, fOrigin2, fMins2);
if(!BoundsIntersect(fMins1, fMaxs1, fMins2, fMaxs2))
{
// Entities do not collide or touch!
}
...........
bool:BoundsIntersect(const Float:mins1[3], const Float:maxs1[3], const Float:mins2[3], const Float:maxs2[3])
{
if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
return false;
if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
return false;
return true;
}
__________________