Hello everyone,
I'm trying to create a function that checks if player is standing in a narrow spot, cause I want him to prevent creating exploding mines in such places. I've received a lot of help from ashkerin, who told me to use TraceHull.
What I do right now is creating a "surface" (it's 1 unit thick), that goes straight up from the ground all the way to the player's head and detects if TR_DidHit() have occured
Code:
bool IsFreeArea(int client) {
float originBegin[3];
GetClientAbsOrigin(client, originBegin);
originBegin[2] += 5.0;
float originEnd[3];
GetClientEyePosition(client, originEnd);
float hullMins[3];
hullMins[0] -= HULL_SIZE;
hullMins[1] -= HULL_SIZE;
float hullMaxs[3];
hullMaxs[0] += HULL_SIZE;
hullMaxs[1] += HULL_SIZE;
hullMaxs[2] += 1.0;
Handle trace = TR_TraceHullFilterEx(originBegin, originEnd, hullMins, hullMaxs, MASK_ALL, TraceEntityFilterPlayer);
bool hit = TR_DidHit(trace);
CloseHandle(trace);
return hit;
}
public bool TraceEntityFilterPlayer(entity, contentsMask) {
return entity > MaxClients;
}
Unfortunately, this solution doesn't work. It returns true in completely random situations.
Am I doing something wrong? Any help would be appreciated.
Thank you in advance
__________________