Raised This Month: $ Target: $400
 0% 

TraceRay Help


Post New Thread Reply   
 
Thread Tools Display Modes
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-11-2008 , 16:58   Re: TraceRay Help
Reply With Quote #11

I've been messing with it some more, and I think to do it like this, we need two tracerays. One to tell if it hit a player and one if it didnt (so it knows where to draw to).
__________________
CrimsonGT is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-12-2008 , 20:07   Re: TraceRay Help
Reply With Quote #12

Yeah, I'm pretty sure there's nothing wrong besides what p3tsin said. I tried this out, which is basically Sollie's code:

Code:
public beamtest(client)
{
    new Float:vAngles[3], Float:vOrigin[3], Float:AnglesVec[3], Float:EndPoint[3], Float:pos[3];

    new Float:Distance = 600.0;

    GetClientEyeAngles(client,vAngles);
    GetClientEyePosition(client,vOrigin);
    GetAngleVectors(vAngles, AnglesVec, NULL_VECTOR, NULL_VECTOR);

    EndPoint[0] = vOrigin[0] + (AnglesVec[0]*Distance);
    EndPoint[1] = vOrigin[1] + (AnglesVec[1]*Distance);
    EndPoint[2] = vOrigin[2] + (AnglesVec[2]*Distance);

    new Handle:trace = TR_TraceRayFilterEx(vOrigin, EndPoint, MASK_SHOT, RayType_EndPoint, TraceEntityFilterPlayer, client);

    if (TR_DidHit(trace))
    {
        new Target = TR_GetEntityIndex(trace);
 
        if ((Target > 0) && (Target <= GetMaxClients()))
        {
            new String:name[64];
            GetClientName(Target, name, sizeof(name));

            PrintToChatAll("Hit a player: %s.", name);
        }
        else
        {
            PrintToChatAll("Hit something other than a player: %d", Target);
        }
    }
    else
    {
        PrintToChatAll("Trace didn't hit.");
    }

    TR_GetEndPosition(pos, trace);
    //draw your beam

    CloseHandle(trace);
}

public bool:TraceEntityFilterPlayer(entity, mask, any:data)
{
    return data != entity;
}
I just changed the one thing mentioned and rearranged the logic for testing what got hit. It works, at least as far as I understand what you guys want to do.
Fyren is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-12-2008 , 20:54   Re: TraceRay Help
Reply With Quote #13

The problem is drawing the beam when theres nothing for it to hit. It starts acting odd. I tried using a second traceray just for that, but its still acting very odd.
__________________
CrimsonGT is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-12-2008 , 22:10   Re: TraceRay Help
Reply With Quote #14

Could you show your code for the beam? I took a look at the coordinates the above returns for the end point and they look fine.
Fyren is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-12-2008 , 22:21   Re: TraceRay Help
Reply With Quote #15

Code:
public Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result)
{
 new Float:BeamOrigin[3], Float:ImpactOrigin[3];
 
 if(GetConVarBool(g_CvarEnable))
 {
  if(StrEqual(weaponname,"tf_weapon_syringegun_medic"))
  {  
   if(GetBeamEndPosition(client, ImpactOrigin))
   {
    GetClientEyePosition(client, BeamOrigin);
    BeamOrigin[2] -= 20.0;
 
    //Draw the lightning beam
    Draw_LightningBeam(BeamOrigin, ImpactOrigin);
   }
  }
 }
}
Basically right now I have mine working where if you shoot a wall within the given distance its fine, if you shoot a player in the given distance its fine, but when you just shoot into thin air, it doesnt act right. It should always draw the beam up to Distance max (600 units) or to the player/object if something gets in its way.

*Edit*

I think the problem when using one traceray is that it doesnt get the 'pos' of the end of the beam since it didnt match the filter. Im not sure though.
__________________

Last edited by CrimsonGT; 10-12-2008 at 22:34.
CrimsonGT is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-13-2008 , 00:12   Re: TraceRay Help
Reply With Quote #16

If you do a RayType_Endpoint and it doesn't hit, calling TR_GetEndPosition gets that same endpoint as expected. Is your ray code significantly different that what Sollie posted? Did you print out what GetEndPosition gives you to check?
Fyren is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 10-13-2008 , 03:55   Re: TraceRay Help
Reply With Quote #17

I got it all working now. Im pretty sure the bug was I was missing an else for the second if statement *sigh* lol. Im still tweaking it, but all the core stuff works. Thanks for the help mate.

Sollie, I will post the stuff here when im done with it if you still need it.
__________________
CrimsonGT is offline
Reply



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 14:57.


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