[ut2k3] PlayerCanSeeMe bug ?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Komrod

New Member
Feb 20, 2003
18
0
0
Visit site
Hi,
im making a flash grenade in ut2k3 and i have problems with the PlayerCanSeeMe function. it s supposed to return true if the object is in the player's view.
it seems that it returns false if the player is 500 unit away but the object is still in the player's view. There is no parameter so i dont know how i can fix it.
Another problem : if the player is near the object but look exactly the opposite way, it returns true.

please help me.
 

Mychaeel

New Member
Actually, PlayerCanSeeMe is supposed to return True server-side when any player can see the object in question. (Client-side it's supposed to return True only if the local player can see it.)

If you want to check whether a player can see an object or not, better implement that check in UnrealScript yourself: First check whether the connecting line between the player and the object is within the player's field of view, and if so, use the LineOfSightTo function in Controller to check whether the player has an actual line of sight to the object.
 
Last edited:

Komrod

New Member
Feb 20, 2003
18
0
0
Visit site
thank you,
now i got a problem with LineOfSightTo, it returns always true.
here is my code :

Code:
foreach VisibleActors( class 'Pawn', Victims, FlashRadius*2, Location )
{
   if  (Victims.Health > 0)
   {
      if (!victims.LineOfSightTo(self)) log("IDontSeeYou");
   }
}

This code is in the grenade object code.
lineOfSightTo returns always true even if the player look the other way
damn
 

Mychaeel

New Member
Yes---that's because LineOfSightTo doesn't take the player's field of view into account.

So, like I said above, you should do that in a first step. See Unreal Wiki: UnrealScript Vector Maths for how to find out the angle between two vectors (the player's view direction and the line between the player and the grenade) and compare it to the player's FovAngle. (You could even scale the flash intensity depending on how directly a player is looking at the grenade when it's exploding...)
 

Komrod

New Member
Feb 20, 2003
18
0
0
Visit site
it works perfectly now.
here if my contribution to the community :

Code:
simulated function FlashPawn()
{
   local Pawn  Victim;
   local float factor, dist;
   local float orientation;

   foreach VisibleActors( class 'Pawn', Victim, FlashRadius*2, Location )
   {
      if  (Victim.Health > 0)
	  {
	     dist = vSize(self.location - victim.location);
	     factor = 1.0-(dist/flashRadius);
	     if (factor<0.0) factor = 0.0;
         orientation = vector(victim.Controller.GetViewRotation()) dot Normal(Location - victim.Location);
         if (orientation < 0.4)
	     {
	        if (factor<0.2) return;
            FlashTime = 0.2;
	        factor = 1.0;
         }
         zh_Pawn(victim).setFlashbang(FlashTime*factor);
      }
   }
}


simulated function Explode(vector HitLocation, vector HitNormal)
{
   FlashPawn();
   super.Explode(hitlocation,hitnormal);
}


this is inside the grenade code



----------------------------------------
Zombie Hunter Total Conversion for UT2k3
http://www.zombiehunter.net/
 
Last edited: