Rotation.pitch = is this a bug or code that is just not added?

Has anyone else run into this. It’s when you get onto a server and your the client the rotation pitch does not update. Works fine in standalone or server host listen games, but then that server side. It seems to be that the client is not getting updated at all.

Let me be more specific on what is going on. I have a spotlightcomponent. I it have attached to a socket on a model that is a flashlight and that in turn is attached to a socket on the weapon which is attached to the pawn. When playing as a client on listen or dedicated server. If i move the players view up or down the light will not follow. If i move it side to side it will follow. just not up or down. but the actor the light is in is following fine. Its like the light is not getting the rotation pitch setting applied to it.

If any of you have a fix that be great.

I got it solved. I will share what i came up with shortly.

Does anyone here know what’s an easy way to flip a number example -25 to +25 or vise versa. In c++ you can just use Num = +(Num) to turn negative into a positive or vise versa but in udk script that does not seem to work. anyone with any ideas

in UTWeapon theres a function called SetPosition() i added a line to my weapon here so it updates on the players tick.



//if your a client and your light is on
if((Role < Role_Authority) && bShowWeaponlight)
{
    ClientSetWeaponsRotationPitch();
}
 

I put into the UTWeapon file a function called ClientSetWeaponsRotationPitch(). I need the controllers pitch only.
This function must invert the pitch or it works backwards.
Then we set it on that part and it is done.
The light will now move up and down the wall on the client as it should.

//the float coming in is always positive


simulated function ClientSetWeaponsRotationPitch()
{
 local vector out_CamLoc;
 local rotator out_CamRot;
 local float OurPitch;

OurPitch = 0.0;
OurPitch = Instigator.Controller.Rotation.Pitch;

   if(WeaponFlashLight != none)
   {    
      WeaponCalcCamera(0.1, out_CamLoc, out_CamRot);
 out_CamRot.pitch = (OurPitch > 0) ? -OurPitch : Set_Positive(OurPitch);
      WeaponFlashLight.SetRotation(out_CamRot);
   }
   return;
}

//actually never gets used as the float coming in is always positive


simulated function float Set_Positive(float Result)
{ 
local string teststring; 
local int Pos; teststring="";

   teststring = string(Result);
//`log("PBGunPart::WeaponCalcCamera() The teststring = "$teststring);
Pos = InStr(teststring,"-");
   teststring = right(teststring,Pos);
//`log("PBGunPart::WeaponCalcCamera() The teststring = "$teststring);
Result = float(teststring); 
return Result;
}

hope this helps.
edited:last function to a simulated not a reliable client and rewrote 1st function to go to last function took out middle function.

Many ways to do this, but here’s one:



Abs(SomeInt) * (SomeInt < 0) ? 1 : -1;


@gamepainters You don’t need ClientSetWeaponsRotation() to be a reliable client rpc call, as it’s the client that is calling this function.

Additionally, you never want to to be calling “reliable” rpc calls every tick, as these block network execution, so could lag out your game significantly.

You say that the flashlight rotation is not replicating, however it is attached to your weapon mesh via a socket. Your weapon location does not replicate either (as far as i’m aware), but rather uses your pawn’s location.

See this function in UTWeapon.uc:



/**
* This function aligns the gun model in the world
*/
simulated event SetPosition(UDKPawn Holder)


In addition; the WeaponAttachment class is used for replicating certain properties of the weapon when viewed on another player (not the local player). It doesn’t need to replicate location or rotation as it’s attached to a pawn (which has all these properties you need).

I would take another look at how you have implemented this, as it seems entirely unnecessary (as you already have rotation available via your Pawn), and could cause you a lot of problems with your network code.

thanks for the reliable tip. when i start the call i should realized that it was the client i’m sending thru and that i did’nt need the reliable client call…

weapon.rotation.pitch is always a 0

“In addition; the WeaponAttachment class is used for replicating certain properties of the weapon when viewed on another player (not the local player)” What do you think i have to do with the flashlight for other players so they can see it? ,replicate the light and color to be seen is working fine. It does need the pitch from the controller. As for the pawns ones, they do it all but the rotation pitch is strange.

try doing it with the pawns rotation or even the instIgators.controller.rotation or that instIgators pawn.rotation.pitch. You will find they wont work. The only rotation that seemed to even be close to working was the controller from the pawn, why no clue. even tho it was inverted. so i just used a hacky way to invert the numbers and it worked.

If you find a rotation that’s not inverted and works fine show me it please. I see the server side is fine but if you check it. Its done differently as the rotation pitch is always a 0. So to replicate it from the server is a waste as its a 0. So you have to find it else where. and inject the right numbers in. I’m all in for least amount of code and the best way to accomplish it but from my findings the pawns rotation did not cut it.

called from utpawn file.
just tested this



if((Role < ROLE_Authority) && bShowWeaponlight && (weapon != none))
{
UTWeapon(weapon).ClientSetWeaponsRotation(Controller.Rotation.pitch);
}
 

and it works fine

tried this



if((Role < ROLE_Authority) && bShowWeaponlight && (weapon != none))
{
UTWeapon(weapon).ClientSetWeaponsRotation(Rotation.pitch);
}
 

no pitch from the pawn its a 0. no up or down
will repeat test with in the weapons file to find a pitch to see if they will work and will post here what i find.
So far the 1st call seems to be the one that works

Is this is in first or third person?

If it’s in third person, then you don’t need to update weapon, as weapon is the first person hands that show in front of the view.

If it’s first person, then something is wrong somewhere in your code, as if you look in UTWeapon.uc SetPosition() it is already doing what you are repeating in the code you are adding:



/**
* This function aligns the gun model in the world
*/
simulated event SetPosition(UDKPawn Holder)
{
   local vector DrawOffset, ViewOffset, FinalSmallWeaponsOffset, FinalLocation;
   local EWeaponHand CurrentHand;
   local rotator NewRotation, FinalRotation, SpecRotation;
   local PlayerController PC;
   local vector2D ViewportSize;
   local bool bIsWideScreen;
   local vector SpecViewLoc;

   if ( !Holder.IsFirstPerson() )
      return;

   // Hide the weapon if hidden
   CurrentHand = GetHand();
   if ( bForceHidden || CurrentHand == HAND_Hidden)
   {
      Mesh.SetHidden(True);
      Holder.ArmsMesh[0].SetHidden(true);
      Holder.ArmsMesh[1].SetHidden(true);
      NewRotation = Holder.GetViewRotation();
      SetLocation(Instigator.GetPawnViewLocation() + (HiddenWeaponsOffset >> NewRotation));
      SetRotation(NewRotation);
      SetBase(Instigator);
      return;
   }
...


As you can see, the weapon location and rotation is getting updated here. So this is where you should test and see why pitch is zero. Don’t add you own code that is doing the same thing though, as that could start getting very messy and difficult to work with.

To clarify:
UTWeapon == The first person players hands/arms.
UTFirearm == The weapon being held in the first person hands.
UTWeaponAttachment == The weapon that shows being held by the 3rd person pawn mesh.

The moving up and down was for the 1st person. I have not been able to test with another person on dedicated yet to see the 3rd person results.

I do notice with my bots when they shoot they are not getting the pitch either as they look up at a player to shoot him. Their gun is pointed at the player but they shoot straight (as in flat).
I hacked the adjusted aim to fix it but it seem to slow the bots action down a lot they act idle at times, so i changed it back to way it was with messed up shooting and they play way better so i’m goin after that next and solve why they get no pitch.

What seems strange to me is that yaw is replicated why is pitch not replicated? and the only reason i could see roll being replicated would be for lean. Question i have is why were they all 3 not replicated over to the clients side?

Back to the light. I have attached a light to both sides 1st and 3rd i set color over in the attachment as the 1st person gun does not seem to want to replicate the color. I also turn it on from the pawn to the The (1st person side, I use the on /off to set battery drain). Then that also heads over to the pawn for the on/off action of the light so it gets replicated to all players to see when turned on. So the 3RD person weapon is what being turned on and off and not the 1st,

then Once i hooked up the 1st person light, the 1st person started acting properly. Just no rotation.pitch.

If you just use 3rd person light ONLY it lags and is slow and wont stay caught up in 1st person. It’s like the frequency of the updates are not fast enough. .So by attaching the 1st person light, that fixed that issue.

only the 3rd person light is what turns on/off. but both lights will share each other properties. So in short i set color, turn off /on thru attachment file to pawn file. On the 1st person side i just attach the same light. I use that side to set battery drainage and play messages to your screen.

here’s my findings on the pitch

[0056.20] ScriptLog: PBPawn::GetViewRotation() start
[0056.20] ScriptLog: PBPawn::GetViewRotation() Controller.Rotation.pitch = 11241
[0056.20] ScriptLog: PBPawn::GetViewRotation() Rotation.pitch = 0
[0056.20] ScriptLog: PBPawn::GetViewRotation() PBPlayerController(Controller).Rotation.pitch = 11241
[0056.20] ScriptLog: PBPawn::GetViewRotation() self.Controller.Rotation.pitch = 11241
[0056.20] ScriptLog: PBPawn::GetViewRotation() self.Rotation.pitch = 0
[0056.20] ScriptLog: PBPawn::GetViewRotation() PBPlayerController(Controller).Rotation.pitch = 11241
[0056.20] ScriptLog: PBPawn::GetViewRotation() end
[0056.20] ScriptLog:

[0056.20] ScriptLog:
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() start
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The Result.pitch = 11241.0000
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The Instigator.Rotation.pitch = 0
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The Instigator.Controller.Rotation.pitch = 11241
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The PBP.Rotation.pitch = 0
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The PBP.Controller.
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The PBP.Controller.Rotation.pitch = 11241
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() PBPlayerController(Instigator.Controller).Rotation.pitch = 11241
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() end
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The Result.pitch = 11241.0000
[0056.20] ScriptLog: PBGunPart::WeaponCalcCamera() The out_CamRot.pitch = -11241

seems controllers are only ones replicating the pitch setting.

I’m going to look into that function
SetPosition(UDKPawn Holder)
but when i log it i get no action that its being used?
will test more and reply back.

Also there should be no over head on the network from this as its already been replicated to the controller. Were getting all this client side so he performing it himself so nothing for server to send to client, it was already there.

Biggest question i have is why was Rotation.pitch not replicated over for use?

Edited the above functions

interesting the function SetPosition is not being used in our code. i have to go back thru what the earlier guys coded that i do not know about. That’s the frustrating part with multiple coders and them not saying what they did and no comments to help you out. I have found multiple things that were done and were(shakes head at it) enough to go why. Enough to frustrate a person.

Are you using that function? I find a lot of functions in this code thats just siting idle and not used is this one of them?

Hmmmm, yes that sounds frustrating if other coders have messed that up. You should definitely use the existing implemented weapon logic if you can, and build on top of it, rather than re-implement what is already there.

Yes we are running the function SetPosition it is in 2 files up that extends utweapon. What do you get if you log this

WeaponCalcCamera(0.1, out_CamLoc, out_CamRot);

`log("out_CamRot.Pitch = "$out_CamRot.Pitch);

As a client. I’m curious what your getting in your log on this setting.

EDIT: Adjusted above functions to their final settings.