logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Viewing from other player in first-person view (Read 3957 times)
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Viewing from other player in first-person view
Nov 9th, 2015 at 3:46pm
Print Post  
In a Coop game a player is usually allowed to observe the game world from the eyes of other player (e.g. using console commands "ViewPlayerNum -1" and "BehindView 0"). There are 2 issues related to such a view:

#1. The variable PlayerPawn.TargetViewRotation that holds the value of ViewRotation of the observed player (taken as ViewTarget) is replicated too roughly, so that on the observer's client rotations of the ViewTarget look jittery and when the observed player injures a target at far distance using a precise weapon that causes damage instantly (e.g. Automag or Rifle), the observer's crosshair often points to a location that noticeably differs from the actual hit location.

I doubt that this issue can be resolved only by changing Engine.u and/or the game executables such as Engine.dll without breaking compatibility with old clients.

A mod can fix it by defining a subclass of PlayerPawn with an overriding definition of PlayerCalcView that would obtain the rotation value from other variable (instead of TargetViewRotation) for which replication is performed precisely. However, subclassing PlayerPawn is not a scalable solution (two mutually independent mods that define their own player classes for different purposes won't mix well when both need to do something specific with the same player).

A scalable solution could exist if there was a way to disable either the automatic modification of TargetViewRotation client-side or its replication to client, so that we could assign a relatively precise value to TargetViewRotation client-side (the value could be transferred from server to client using an auxiliary variable in an auxiliary actor) and then there would be no undesirable client-side modifications of TargetViewRotation prior to the subsequent call to PlayerCalcView (such undesirable client-side modification takes place when TargetViewRotation is replicated to client).

So, my proposal is to add boolean variable bUpdateTargetViewRotation in class Engine.PlayerPawn with default value bUpdateTargetViewRotation=True and change the automatic modification of TargetViewRotation such that it would take place only if bUpdateTargetViewRotation is True.

#2. This is how Dispersion Pistol sometimes looks when the holder's Handedness is set to "Hidden":



This issue can potentially be resolved by changing the algorithm of evaluation of Engine.PlayerPawn.TargetWeaponViewOffset, but I can't suggest anything concrete without knowing the algorithm.

A solution with a mod can be easy: it's possible to replicate the server-side value of Weapon.bHideWeapon to client by means of an aux variable and then assign it to the corresponding bHideWeapon client-side. When bHideWeapon is true on client, the weapon is not drawed.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7923
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Viewing from other player in first-person view
Reply #1 - Mar 9th, 2016 at 7:34am
Print Post  
Need to work me into this matter first I think. For what I can say now is, that if there is PlayerPawn && PlayerPawn->ViewTarget we have

Code (C++)
Select All
PlayerPawn->TargetViewRotation = TargetPawn->ViewRotation;
PlayerPawn->TargetEyeHeight = TargetPawn->EyeHeight;
if ( TargetPawn->Weapon )
PlayerPawn->TargetWeaponViewOffset = TargetPawn->Weapon->PlayerViewOffset; 



while bHideWeapon should be replicated in any case too.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #2 - Mar 9th, 2016 at 9:57am
Print Post  
Smirftsch wrote on Mar 9th, 2016 at 7:34am:
while bHideWeapon should be replicated in any case too.

It's replicated only to the net owner:

Code
Select All
	reliable if ( Role==ROLE_Authority && bNetOwner )
		AmmoType, bLockedOn, bHideWeapon; 


which is equivalent to

Code
Select All
	reliable if ( Role==ROLE_Authority && Level.ReplicationTarget == Owner )
		AmmoType, bLockedOn, bHideWeapon; 


while covering the case of spectators needs a condition that would be equivalent to

Code
Select All
	reliable if ( Role==ROLE_Authority && Owner != none && (Level.ReplicationTarget == Owner || Level.ReplicationTarget.ViewTarget == Owner) )
		AmmoType, bLockedOn, bHideWeapon; 



So, I see two options:
1) Modifying the replication statement for bHideWeapon.
2) Adding some hack to Weapon.SetHand:

Code
Select All
function setHand(float Hand)
{
	if ( Hand == 2 )
	{
		PlayerViewOffset.X = default.PlayerViewOffset.X;
		PlayerViewOffset.Y = 0;
		PlayerViewOffset.Z = default.PlayerViewOffset.Z - 100; // move the weapon out of the field of view
		FireOffset.Y = 0;
		bHideWeapon = true;
		return;
	}
	else
		bHideWeapon = false;
.... 

  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7923
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Viewing from other player in first-person view
Reply #3 - Mar 9th, 2016 at 4:17pm
Print Post  
if there is no other reason than spectator, I indeed tend to use the hack in this case.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Viewing from other player in first-person view
Reply #4 - Mar 9th, 2016 at 5:17pm
Print Post  
re: Level.ReplicationTarget == Owner || Level.ReplicationTarget.ViewTarget == Owner

Is there no other way to tell if a pawn is currently being viewtargeted?

that seems really heavy handed, especially when multiple pawns can be viewed..

edit: ViewClass is also used in coop games to see what another player is doing, so its not just a spectator hack
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #5 - Mar 9th, 2016 at 5:57pm
Print Post  
Smirftsch wrote on Mar 9th, 2016 at 4:17pm:
if there is no other reason than spectator, I indeed tend to use the hack in this case.

Theoretically, option 1 should be more reliable (SetHand can be overridden in subclasses). But I don't have strong preferences here.
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Viewing from other player in first-person view
Reply #6 - Mar 9th, 2016 at 6:23pm
Print Post  
If the replication statement was changed to remove "&& bNetOwner" it should solve that particular piece of the puzzle forever

I know of a few mods that override sethand, and replication statements are not easily overridden
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7923
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Viewing from other player in first-person view
Reply #7 - Mar 10th, 2016 at 4:47pm
Print Post  
alright. Anything else in need to be changed additionally aside this to close this topic then ? Smiley

  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #8 - Mar 10th, 2016 at 5:05pm
Print Post  
Removing "&& bNetOwner" is sufficient. The question is whether such a change should affect AmmoType and bLockedOn (listed in the same replication statement).
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Viewing from other player in first-person view
Reply #9 - Mar 10th, 2016 at 5:18pm
Print Post  
If you change the contents of a replication statement, like removing AmmoType and bLockedOn, it breaks replication to old versions. As far as I know, there's no workaround for this.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #10 - Mar 10th, 2016 at 5:31pm
Print Post  
[]KAOS[]Casey wrote on Mar 10th, 2016 at 5:18pm:
If you change the contents of a replication statement, like removing AmmoType and bLockedOn, it breaks replication to old versions. As far as I know, there's no workaround for this.

Wish I knew how that stuff works. I can't imagine a reasonable implementation that would have such problems.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #11 - Mar 10th, 2016 at 6:27pm
Print Post  
I tried to experiment with different replication statements on server and client sides. As far as I can see, a single replication statement with multiple variables can be split into several different replication statements, that would cover the same set of variables together, without negative consequences. It's not even necessary to preserve the order in which the variables are listed. For example,

Code
Select All
var string s0;
var int i1;
var string s2;
var int i3;

replication
{
	reliable if (Role == ROLE_Authority)
		s0, i1, s2, i3;
} 


can be transformed into

Code
Select All
var string s0;
var int i1;
var string s2;
var int i3;

replication
{
	reliable if (Role == ROLE_Authority)
		i3;
	reliable if (Role == ROLE_Authority)
		i1;
	reliable if (Role == ROLE_Authority)
		s2;
	reliable if (Role == ROLE_Authority)
		s0;
} 


So, I presume, we can change

Code
Select All
	reliable if ( Role==ROLE_Authority && bNetOwner )
		AmmoType, bLockedOn, bHideWeapon;  


to

Code
Select All
	reliable if ( Role==ROLE_Authority && bNetOwner )
		AmmoType;

	reliable if ( Role==ROLE_Authority )
		bLockedOn, bHideWeapon; 


or

Code
Select All
	reliable if ( Role==ROLE_Authority && bNetOwner )
		AmmoType, bLockedOn;

	reliable if ( Role==ROLE_Authority )
		bHideWeapon; 

  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Viewing from other player in first-person view
Reply #12 - Mar 10th, 2016 at 7:07pm
Print Post  
hmm...

It has been years since I tested, but as far as I remember the reasons we wanted to change replication statements was to add new variables to replicate. Maybe it was an incorrect assumption that splitting statements breaks things too.

Perhaps it only breaks on the replication table as a whole, i.e. ClassX has 5 replication variables in some version of code, and ClassX has 6 variables in another, which when sending data across there's a size/map mismatch and it goes nuclear.

Did you perform a ucc conform to the first build of the package when testing this? Guess you would have to, since otherwise you'd get a version mismatch.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Viewing from other player in first-person view
Reply #13 - Mar 10th, 2016 at 7:12pm
Print Post  
[]KAOS[]Casey wrote on Mar 10th, 2016 at 7:07pm:
Perhaps it only breaks on the replication table as a whole, i.e. ClassX has 5 replication variables in some version of code, and ClassX has 6 variables in another, which when sending data across there's a size/map mismatch and it goes nuclear.

Yes, I can confirm that adding a variable to or removing it from the initial overall set of replicated variables for a class breaks the replication.

Quote:
Did you perform a ucc conform to the first build of the package when testing this?

Yes.
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: Viewing from other player in first-person view
Reply #14 - Mar 10th, 2016 at 8:27pm
Print Post  
Well, this changes things. I'd like to see how a test build of 227j with this change works. I assume it will have no issue, obviously.

I wonder what other replication statements could be moved to make better sense for if/when to replicate...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo