PeripheralVision

Discussions about UT99
User avatar
OjitroC
Godlike
Posts: 3686
Joined: Sat Sep 12, 2015 8:46 pm

PeripheralVision

Post by OjitroC »

Am I right in thinking that, if one wants a Pawn to have normal peripheral vision (the ability when looking straight ahead to see objects at the side but not behind - so to see 180 degrees when looking straight ahead), the PeripheralVision value should be set to -1.00000? Or does that value mean that the Pawn can see behind as well?
User avatar
Barbie
Godlike
Posts: 2831
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: PeripheralVision

Post by Barbie »

According to the comment in Pawn.uc

Code: Select all

var(AI) float		PeripheralVision;//Cosine of limits of peripheral vision.
and the values of Cosine (see below) I suspect that it describes the field of view (FoV) where Pawns can see things.

for PeripheralVision=1 the FoV is 0 (useless)
PeripheralVision=0 means a FoV from -π/2 to +π/2 = -90° to +90°, so all in all 180°
if and only if FoV can go over 180°, PeripheralVision=-1 would mean a FoV from -π to +π what is a full cycle (360°)

Correct me, if I'm wrong.
You do not have the required permissions to view the files attached to this post.
"If Origin not in center it be not in center." --Buggie
User avatar
OjitroC
Godlike
Posts: 3686
Joined: Sat Sep 12, 2015 8:46 pm

Re: PeripheralVision

Post by OjitroC »

Thanks for that explanation.

So, in relation to ScriptedPawns, the default value for PeripheralVision of 0.0000 means that they can see 180 degrees when looking straight ahead (45 degrees either side of the normal PoV of 90 degrees). Setting that value to -1.0000 would give them the ability to see behind (360 degrees).

Giving them a positive value for PeripheralVision limits the extent to which they can see (as does a negative value of more than -1).
User avatar
Barbie
Godlike
Posts: 2831
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: PeripheralVision

Post by Barbie »

OjitroC wrote: Fri Jun 02, 2023 8:13 am Giving them a positive value for PeripheralVision limits the extent to which they can see
Yes, even a FoV of 0 (PeripheralVision=1) is used, for example for a dice playing Krall:

Code: Select all

function PreBeginPlay() {
	...
	if ( bDicePlayer ) PeripheralVision = 1.0; 
OjitroC wrote: Fri Jun 02, 2023 8:13 am Setting that value to -1.0000 would give them the ability to see behind (360 degrees).
According to function Bot.SetPeripheralVision() more than a FoV of 180° can be used, because Skill can have a value up to 3:
PeripheralVision = 0.65 - 0.33 * skill;
some default PeripheralVision values

Code: Select all

Actor@Engine.u/Pawn@Engine.u/FlockMasterPawn@UnrealShare.u/HorseFlySwarm/HorseFlySwarm.uc:     PeripheralVision=-5.000000
Actor@Engine.u/Pawn@Engine.u/FlockMasterPawn@UnrealShare.u/ParentBlob@UnrealI.u/ParentBlob.uc:     PeripheralVision=-5.000000
Actor@Engine.u/Pawn@Engine.u/FlockMasterPawn@UnrealShare.u/BiterFishSchool/BiterFishSchool.uc:     PeripheralVision=-5.000000
Actor@Engine.u/Pawn@Engine.u/FlockPawn@UnrealShare.u/NaliRabbit/NaliRabbit.uc:     PeripheralVision=-10.000000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/ScriptedPawn.uc:		PeripheralVision += 0.707 * (Alertness - NewAlertness); //Used by engine for SeePlayer()
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Tentacle@UnrealShare.u/Tentacle.uc:     PeripheralVision=-2.000000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Pupae@UnrealI.u/Pupae.uc:     PeripheralVision=-0.400000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/TWT_ZombiePawn@TWT_Zombies.u/TWT_ZombiePawn.uc:    PeripheralVision=-5.00
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Sheep@Pearman.u/Sheep.uc:    PeripheralVision=-10.00
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Squid@UnrealI.u/Squid.uc:     PeripheralVision=-0.500000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/UMSsp@UMSSpaceMarine.u/spb@UMSSpaceMarine.u/spb.uc:		PeripheralVision = -0.1;
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/UMSsp@UMSSpaceMarine.u/spb@UMSSpaceMarine.u/spb.uc:		PeripheralVision = 0.7 - 0.35 * skill;
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Rsp@u2rtnp.u/Hybrid@u2rtnp.u/Hybrid.uc:		PeripheralVision = -0.1;
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Rsp@u2rtnp.u/Hybrid@u2rtnp.u/Hybrid.uc:		PeripheralVision = 0.7 - 0.35 * skill;
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Cow@UnrealShare.u/Cow.uc:     PeripheralVision=-10.000000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/KingCobra@KingCobra.u/KingCobra.uc:    PeripheralVision=-0.40
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Predator@UPak.u/Predator.uc:      PeripheralVision=-1.000000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Fly@UnrealShare.u/Fly.uc:     PeripheralVision=-0.500000
Actor@Engine.u/Pawn@Engine.u/ScriptedPawn@UnrealShare.u/Scorpion@Scorpion.u/Scorpion.uc:    PeripheralVision=0.40
Interesting: NaliRabbit and Cow have a PeripheralVision of -10!   
Auto merged new post submitted 9 minutes later
Attached a map where a trigger changes Krall's PeripheralVision to -1.
The needed SBPropertyChangerV1 can be found here.
spoiler for result
Do you really want to see the result?
Spoiler
Yes, obviously PeripheralVision=-1 means a 360° FoV.
You do not have the required permissions to view the files attached to this post.
"If Origin not in center it be not in center." --Buggie
User avatar
sektor2111
Godlike
Posts: 6419
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: PeripheralVision

Post by sektor2111 »

I operated some changes in my mod because some Tentacles were really useless and other monsters were "set" by "creative" mappers on purpose to gain them sleepy and useless too... - 4-5 years ago...

Code: Select all

function SetPawnDifficulty( ScriptedPawn S )
...
...
	if (S.PeripheralVision < -1.6) S.PeripheralVision = -1.6;
	if (S.PeripheralVision > -0.2) S.PeripheralVision = -0.2;
...
It's not like my mods are accepting too many dumb ideas.
In other map some Skaarjs were just waiting to get killed - they were set with -60 at this point... I'm not surprised about lousy things in a server with so many "smart" settings in maps...
User avatar
OjitroC
Godlike
Posts: 3686
Joined: Sat Sep 12, 2015 8:46 pm

Re: PeripheralVision

Post by OjitroC »

sektor2111 wrote: Fri Jun 02, 2023 6:50 pm I operated some changes in my mod because some Tentacles were really useless and other monsters were "set" by "creative" mappers on purpose to gain them sleepy and useless too... - 4-5 years ago...

Code: Select all

function SetPawnDifficulty( ScriptedPawn S )
...
...
	if (S.PeripheralVision < -1.6) S.PeripheralVision = -1.6;
	if (S.PeripheralVision > -0.2) S.PeripheralVision = -0.2;
...
It's not like my mods are accepting too many dumb ideas.
In other map some Skaarjs were just waiting to get killed - they were set with -60 at this point... I'm not surprised about lousy things in a server with so many "smart" settings in maps...
I'm a bit confused here - surely the cosine should be between -1 and 1 - a cosine of -1.6 can't exist?   
Auto merged new post submitted 3 hours 18 minutes later
OK, so this is odd - using Barbie's test map (many thanks for that) and setting the PeripheralVision value in the SBPropertyChanger at -1, -10 and -100 results in the same outcome - the Krall will turn and attack when triggered (which means it 'sees' the Player behind it).

This suggests that the PeripheralVision value isn't a cosine (unlikely?) or that the 'Engine' reads any negative value in excess of -1 as -1.

Setting the PeripheralVision value at a positive value of more than 1 results in the Krall not attacking when triggered. Set it high enough (like 10) and the result is that the Krall does not see the Player at all, even when standing directly in front of it - something I have previously experienced in a MH map with pawns with a PeripheralVision value in the 1000s.

The unexpected result is that setting the PeripheralVision value at a large negative value (-10 or -100) or, indeed, at a negative value of more than -1 triggers the Krall. The expected results are those obtained with the positive values.
User avatar
Barbie
Godlike
Posts: 2831
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: PeripheralVision

Post by Barbie »

Never trust foreign incoming values! - That should be a guide line for coders. Because a cosine outside the interval [-1, +1] is not possible, I'd clamp a user generated value into this interval before using the value for anything else. Hopefully the UT coders did the same.
Setting the PeripheralVision value at a positive value of more than 1 results in the Krall not attacking when triggered.
Even PeripheralVision=1 is enough to make a pawn blind. Higher values make a pawn even blinder (joke). See dice playing Krall code example above.
"If Origin not in center it be not in center." --Buggie
Eternity
Skilled
Posts: 176
Joined: Sat Nov 30, 2019 10:56 pm

Re: PeripheralVision

Post by Eternity »

Maybe it's something like y=2*arccos(x).
But then question is - why Epic used PeripheralVision default values such as -2, -5 and -10 for some pawns...
User avatar
sektor2111
Godlike
Posts: 6419
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: PeripheralVision

Post by sektor2111 »

In comment is clearly specified that it's about a "cosine blah blah", me one after doing an experiment, and this "cosine" being set as "float" which can be ugly screwed, I went to the conclusion that Pawn should stay in more "normal" ranges or else it goes useless. Cosine or not, what is being under -2 here is not helpful, neither if is positive.
OjitroC wrote: Fri Jun 02, 2023 10:59 pm I'm a bit confused here - surely the cosine should be between -1 and 1 - a cosine of -1.6 can't exist?
Logically it should not be out of -1 - 1 but UE1 has another logic of things so get used with it, and bubbles from this engine are more than that...
My choice was done behind playing with test maps (copies or used maps) - especially for Tentacles subject (namely BoomBoomBridge, LandsOfEternalSunset, and such). Clearly to me Pawns should be normal disregarding what Epic or others decided.
In other hand, Mod can be delegated to expand "SeePlayer" a bit different and then... dumb values added by mappers are just useless, my mod has the word in how I play MH not mapper the mostly not knowing what he does.

In mean time you can ignore some of their comments because I think their codes are wrong anyway. A sample of a lousy comment + code

Code: Select all

//=============================================================================
// AI functions.

//
// Inform other creatures that you've made a noise
// they might hear (they are sent a HearNoise message)
// Senders of MakeNoise should have an instigator if they are not pawns.
//
native(512) final function MakeNoise( float Loudness );

//
// PlayerCanSeeMe returns true if some player has a line of sight to 
// actor's location.
//
native(532) final function bool PlayerCanSeeMe();

//=============================================================================
And now Sektor will ask: What does that Means A.I. functions ? These were placed in Actor class not Pawn. ANY Actor can make noise and stupidly checking if Owner of a NetConnection can see it - yeah let's see what's up with fake connections which UT can deploy itself closing them later. This is why PlayerCanSeeMe was crashing, not because of Bot. The rest of bool result code is a piece of crap, we can call this "MyButtCanSeeIt" in the way how it works - test map it's already in forum and there is a video on YouTube too... In 227 and XC_Engine this is clearly improved.
User avatar
Barbie
Godlike
Posts: 2831
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: PeripheralVision

Post by Barbie »

Hmm, what is the relation between PeripheralVision and Pawn's FovAngle? :???:

Code: Select all

var() float      FovAngle;      // X field of view angle in degrees, usually 90.
Classes with different default values
GasBag: 120
CHSpectator and PlayerPawn: dynamically changed
StationaryPawn: 0 (TeamCannon gets 90 again)
"If Origin not in center it be not in center." --Buggie
User avatar
OjitroC
Godlike
Posts: 3686
Joined: Sat Sep 12, 2015 8:46 pm

Re: PeripheralVision

Post by OjitroC »

I assume that PeripheralVision is the field of view beyond the FoV.

So a PeripheralVision value of 0 adds 90 degrees to the default FoV, meaning that a Pawn can see 180 degrees when looking straight ahead (less than a normal human FoV).

A negative PeripheralVision value (of whatever size) means the Pawn can see behind. The maximum negative PeripheralValue should be -1 (meaning the Pawn can see 360 degrees) - however it can be set to a greater value as once the value exceeds -1 (and hence 360 degrees) it is not possible to see any further in the horizontal plane. Setting the value to -10 has the same effect as setting it to -1 and a value of -10 can not reduce or increase the extent of peripheral vision as it exceeds -1.

A positive PeripheralVision value is more problematic. Setting the value to 1.000000 should, in theory, totally limit the Pawn's vision - however testing with the Krall in the test map indicates that the Krall still has some FoV with the PeripheralVision Value at 1. Setting the Value at more than 1 results in the Pawn being totally 'blind' (I have tested with values of 2 or more, but not with values between 1 and 2). Again, as with the negative value, setting a very high positive PeripheralVision value can have no more or greater effect than setting it at 2 as it is impossible to reduce the field of vision once the point of no vision has been passed.

So my conclusion, based solely on testing with the Krall, is that a PeripheralVision value of 1.000000 results in no PeripheralVision but does not reduce the Krall's FoV (or, at least, does not reduce it totally - it's obviously not possible to say what it does reduce the FoV to solely from a test using a Pawn).

Quite how all this works in the code I don't know - this is the only significant reference to PeripheralVision (in Engine.Pawn)

Code: Select all

// CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
native(533) final function bool CanSee(actor Other);