Raised This Month: $12 Target: $400
 3% 

TraceHull error?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-10-2020 , 10:29   TraceHull error?
Reply With Quote #1

PHP Code:

float origin
[3];
GetClientAbsOrigin(clientorigin);
    
TR_TraceHullFilter(originoriginview_as<float>({-64.0, -64.00.0}), view_as<float>({64.064.00.0}), MASK_SOLIDTraceFilter_Traps);
bool result TR_DidHit();
PrintToChatAll("result %d"ent); // print: result 0

public bool TraceFilter_Traps(int entityint mask)
{
    if (
entity && entity <= MaxClients || !IsValidEntity(entity))
    {
        return 
false;
    }
    
    
char classname[128];
    
GetEntityClassname(entityclassnamesizeof(classname));
    
    if (
StrEqual(classname"func_door"true))
    {
        
PrintToChatAll("ent %s"classname); // this prints entity name if i am in its range
        
return true;
    }
    
    return 
false;

I'm trying to check if players are close to a func_door (or func_rotating, door_rotating, train etc, doesn't matter). If i'm close to a func_door, TraceFilter_Traps will print in chat the entity classname.
Example: ent func_door.
So, i'm returning true.
https://sm.alliedmods.net/new-api/sd...ceEntityFilter
"True to allow the current entity to be hit, otherwise false."

But when i check for TR_DidHit or TR_GetEntityIndex, the result will be: no collision. TR_DidHit returns 0 and TR_GetEntityIndex returns -1. What's wrong?
__________________
Ilusion9 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-10-2020 , 17:30   Re: TraceHull error?
Reply With Quote #2

solved
PHP Code:

    float origin
[3];
    
GetClientAbsOrigin(clientorigin);
    
    
float vEndPos[3];
    
vEndPos[0] = origin[0];
    
vEndPos[1] = origin[1];
    
vEndPos[2] = origin[2] - 2.0;
    
    
TR_TraceHullFilter(originvEndPosview_as<float>({-64.0, -64.00.0}), view_as<float>({64.064.00.0}), MASK_SOLIDTraceFilter_Traps); 
__________________
Ilusion9 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode