I don't think you can do what you're doing with the native trace functions, so you'll have to approach this differently.
You could iterate through all the list of visible actors, and for each light close by, calculate the distance (as a vector) between the player and the light. The closer he is to the light, the more detectable he is. To make the effect more realistic, I'd do something similar on the enemy class: Get the distance to the player's pawn and the closer the enemy gets, the higher the chance of being detected.
Pseudocode:
The Player's pawn:
Code:
var float visibility;
function calculateVisibility
{
foreach VisibleActors(class'MyLight', outLight, 1024) //iterate through the list of visible actors of class 'myLight' in a radius of 1024 units
{
visibility = 0; // Set detectability to 0 just to be safe
if(FastTrace(self.location, outLight.location) && VSize(PlayerController.Pawn.location - outLight.location) != 0) // The player might be close the light, but it might be around a corner and we do not want to divide by 0
{
visibility += 1 / abs(VSize(PlayerController.Pawn.location - outLight.location) // Increase detectability for every light
}
}
}
On your enemy:
Code:
var float proximity;
function calculateProximity
{
if (VSize(PlayerController.Pawn.location - self.Location != 0))
{
proximity = 1 / abs(VSize(PlayerController.Pawn.location - self.Location);
if (PlayerController.Pawn.visibility + proximity >= 1)
{
// Whatever happens now
}
}
}
You'd have to do this very often (probably in a tick function on both classes) plus iterating through the list of all visible actors is really expensive in terms of processing power though so it might not be a great solution.
Bookmarks