I have the following code that warps the farthest bot to where I am pointing.
It works perfectly when pointing at the floor but
when pointing to a wall or other things it places the bots into them and they get stuck.
Is there a way to do the trace to keep them from being placed into things and being stuck?
tx
PHP Code:
public Action Command_warpFarBot(int client, int args)
{
float clientPos[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", clientPos);
int farthestBotIndex = getFarthestBot(client);
new Float:g_Origin[3];
new Float:g_Angle[3];
new Float:normal[3];
GetClientEyePosition(client, g_Origin);
GetClientEyeAngles(client, g_Angle);
TR_TraceRayFilter(g_Origin, g_Angle, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, client);
//TR_TraceRayFilter(g_Origin, g_Angle, MASK_OPAQUE, RayType_Infinite, TraceRayDontHitSelf, client);
if(TR_DidHit(INVALID_HANDLE))
{
//TR_GetSurfaceName(INVALID_HANDLE,tmp, 255);
//PrintToChat(client, "[Surface]= %s", tmp);
TR_GetEndPosition(g_Origin);
TR_GetPlaneNormal(INVALID_HANDLE, normal);
GetVectorAngles(normal, normal);
normal[0] += 90.0;
TeleportEntity(farthestBotIndex, g_Origin, normal, NULL_VECTOR);
//TeleportEntity(farthestBotIndex, g_Origin, g_Angle, NULL_VECTOR);
//TeleportEntity(ent, end, normal, NULL_VECTOR);
PrintToChat(client, "[SM] Teleported %N to you.", farthestBotIndex);
}