Download

Detect Speed of Turn

The player can possess another pawn and after possessing it the speed of their rotation can vary ( I notice on slower PC’s the speed is slower then more powerful PC’s).

I have enabled in game a means whereby the player can adjust their speed of rotation either to slow or speed up by updating the value of PlayerInput.aStrafe in the PlayerWalking state. This all works fine.

What I’d like to do is to automatically detect the speed and adjust it accordingly. I thought I’d try this by getting 2 vectors and checking the distance between the players rotation. If it is too large a distance I adjust PlayerInput.aStrafe to slow them down.

It sort of works but not too well, anyone got a better way of doing this, or can spot a flaw in what I’ve tried.



 
simulated state PlayerWalking
{
    simulated function PlayerMove(float DeltaTime)
    {
   
// snippet of code that I added into this function ...
 
				if (doVect1)
				{
					vect1 = vector(pawn.GetViewRotation());
					doVect1 = false;
				}
				else
				{
					vect2 = vector(pawn.GetViewRotation());
					doVect1 = true;
				}
				
				if (!IsZero(vect1) && !IsZero(vect2))
				{
					distTurn = VSize(vect1 - vect2);
					`log("****** Disabled STRAFER strafe Turn ************"$distTurn);
				}
				
				if (distTurn > 0.002)
				{
					PlayerInput.aStrafe = PlayerInput.aStrafe/4;
				}      

     }
}





I immediately thought of BobDamping, and then PitLag/YawLag. BobDamping is movement up/down relative to the player’s speed and you’re asking about turns relative to speed - it is modifying PlayerInput. The BobDamp number is of course fixed according the Dev’s choice defProperties but it could be made to change. PitchLag/Yaw numbers are also fixed in defProperties.

UTPawn



simulated function vector WeaponBob(float BobDamping, float JumpDamping)
{
	Local Vector WBob;

	WBob = BobDamping * WalkBob;
	WBob.Z = (0.45 + 0.55 * BobDamping)*WalkBob.Z;
	if ( !bWeaponBob )
	{
		WBob *= 2.5;
	}
	WBob.Z += JumpDamping *(LandBob - JumpBob);
	return WBob;
}


I’m not sure if you’re still working on your horse here, and you’re looking for some indecisiveness in its turn, which is indeed noticeable when ‘steering’ a horse, so pitch/Yaw lag would be appropriate. Whereas turning with a gun Pitch/Yaw (as in UTWeapon: simulated event SetPosition(UDKPawn Holder)) isn’t something I’d noticed in gun handling, so it irritated me and I turned it off.

Maybe you’ve already looked through these options, in which case I’m of no help, but maybe someone else will be more helpful.

Not tried those, I’ll have a play and yeah its horse related. Thanks.

Left this for a few days as thought I’d take a look at it fresh. Saw the answer immediately, obviously I was over thinking this before, just needed to use deltatime



				if (PlayerInput.aStrafe != 0)
					PlayerInput.aStrafe = PlayerInput.aStrafe * deltatime * turnOffset;