Skip to content

Player TraceLine issue #7

Description

@guljam

I am using the Player :: GetNearByLocation function to spawn Special infected better than Director.

The problem is the Player :: CanTraceToLocation function when trying to find a place that Survivor can not see.
This is theoretically no problem.

Returning Utils.AreVectorsEqual (m_trace.pos, finish) on some maps is problematic.

For example, in map c2m5_concert.
GetNearByLocation finds a position in the tilted audience chair Navmash and when CanTraceToLocation decides.
It returns a false value with an error of Z axis (difference of 0.00035 for example) with a very slight difference.
It is also the same when the player is placed in a tilted navmash.

The conclusion is that the player can see its position, but the CanTraceToLocation function returns false.
So I modified it to "Utils.CalculateDistance (arr [i], m_trace.pos) <15) return true".
And with a little tolerance, I solved this problem.

So VSLib :: Utils :: SpawnZombieNearPlayer has a problem. I used this at first. It did not work well.
TraceMask should use MASK_OPAQUE. (Reason: transparent white barbed wire for example c2m2_fairgrounds)
I do not know why it traces the 128-height of the Z-axis. The general eye level of special infected is about 60.

Below is the function I created. Trace values ​​are returned more naturally in real situations.


function VSLib::Player::CanTraceLocationAround (where, tolerance = 15, traceMask = MASK_OPAQUE)
{
if(!IsEntityValid()) return;
if(!IsAlive()) return;

local eyepos = GetEyePosition();
local eyeang = GetEyeAngles();

local whereL = where + eyeang.Left().Scale(15);
local whereR = where + eyeang.Left().Scale(-15);

local arr =[where, whereL, whereR];

for(local i = 0; i < 2; i++)
{
	local m_trace = { start = eyepos, end = arr[i], ignore = _ent, mask = traceMask };
	TraceLine(m_trace);

	if(Utils.CalculateDistance(arr[i], m_trace.pos) < tolerance)
	{
		return true;
	}
}

return false;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions