Light Levels?

  • 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.

Nial

New Member
May 21, 2004
12
0
0
Is it possible to check how much light a pawn is in? Preferrably, i'd like to find out how much lighting the Player Pawn is in.
 

Nial

New Member
May 21, 2004
12
0
0
That was helpful, but i'm still having problems. For anyone interested i'm working with Postal 2. I've got this code inside 'ASHUD.uc' which extends 'P2HUD.uc' which inturn extends the original HUD file. Basically everytime the health display is updated, I print the value returned by FindLight() to the screen using this code:

Code:
	UseLight = FindLight();

	MyFont.DrawTextEx(Canvas, CanvasWidth, 
		((IconPos[HealthIndex].X + HUD_NUMBERS_OFFSET_X) * CanvasWidth - 100),
		(IconPos[HealthIndex].Y + HUD_NUMBERS_OFFSET_Y) * CanvasHeight,
		""$UseLight, 2);

This works but always outputs 0.00. What I want it to display is how much light the player is in.

Below is my 'FindLight()' function.

Code:
Function Float FindLight()
{
	Local Actor L;
	Local Float Lx,Ly,Lz,D,LB,F;
	Local Vector Loc;

	Loc=OurPlayer.Location;
	foreach VisibleActors(Class'Actor', L,L.LightRadius,Loc) 
	{
	  if ( L.LightType != LT_None && FastTrace(Loc, L.Location) ) {
			Lx=(L.Location.x-Loc.x);
			Ly=(L.Location.y-Loc.y);
			Lz=(L.Location.z-Loc.z);
			D=Lx+Ly+Lz;	
			LB=L.LightBrightness*L.LightRadius;
			F=LB/D;
			If(F>1) F=1;
			If(F<0) F=0;
		}
	}
	Return (F);
}
 

meowcat

take a chance
Jun 7, 2001
803
3
18
Three things you might want to do.

-Since you are iterating through actors you might have one problem to begin with. The search radius that you are searching is probably 0 (since your local variable L is an actor and not a light, and actor's default light radius is 0). Even for a Light, its default radius is 64 uus.

-Also are you sure you want to calculate F that way?. If the light is anywhere in relation to the player that is "more negative" than you, you might get a lot of F=0. You might want to calculate D as the magnitude of the vector L.location - Loc ie: D=VSize(L.Location -Loc); that way you will get a distance to the light (if that is what you want)

-You might want to see if you can put some log statements in the findlight function so that when it finds an actor with a lighttype it prints out the name of the light. Downside of this is that it may call it several times a tick, so maybe not such a good idea.
 
Last edited:

Bonehed316

New Member
Oct 15, 2001
208
0
0
41
Florida
Visit site
Code:
			Lx=(L.Location.x-Loc.x);
			Ly=(L.Location.y-Loc.y);
			Lz=(L.Location.z-Loc.z);
			D=Lx+Ly+Lz;	
			LB=L.LightBrightness*L.LightRadius;
			F=LB/D;
			If(F>1) F=1;
			If(F<0) F=0;

this bugs me. rewrite this as:
Code:
D=VSize(L.Location.z-Loc.z);
B=L.LightBrightness*L.LightRadius;
F=LB/D;
FClamp(F,0,1);