PDA

View Full Version : Tweaking Controls almost done, just one last thing needed.



Graylord
09-05-2011, 11:26 AM
Alright, let's just start from the beginning.

I have a bone controller. And it controls fine. However, I want make it behave slightly different.


Controller.GetPlayerViewPoint( POVLoc, POVRot );

DesiredTorsoRotation.Yaw = POVRot.Yaw - Rotation.Yaw;
DesiredTorsoRotation.Pitch = 0;

TorsoRotationControl.BoneRotation = DesiredTorsoRotation;

This is how the rotation is done currently.
The behaviour it currently gives, is that it follows the rotation of the camera exactly. As you can see, no rotation rates are involved, it's directly dependent on camera, which is directly dependent on the mouse input.

However, I want it to "hang" after the rotation of the camera, think of controlling a slow cannon or turret, that can't keep up with your aiming.

So what I am trying to do, is making it have a fixed rotation rate, to make it not able to keep up with camera if the player is too fast, or clamp the rotation, but then I need a rotation rate to clamp in the first place.
However, I also want it to ease in and out, so I also want to interpolate it.

I know how to set a rotation rate, and I know interpolate towards a wanted rotation. But I cannot see how to rotate towards a wanted rotation, at a certain rate. I don't want it to keep rotating after the target is reached, after all.


(The last thread was a mess, containing mostly stuff unrelated to the actual problem. I'm pretty sure I need new eyes on the problem, and all the useless stuff would keep a lot of people away, so I needed to make a new thread.)

he3117
09-05-2011, 11:42 AM
I think your question is not clear(at least for me).


As you can see, no rotation rates are involved

and then


think of controlling a slow cannon or turret, that can't keep up with your aiming.

for me slow cannon means for example it can rotate only 10 degree each second.
Am I right?(if so maybe I can help you)

Carsten
09-05-2011, 11:49 AM
are you using facerotation?

This is something i once made :)
You'll know what to use



event Tick(float deltaTime)
{
chargeDelay++;

//`log("chargewait");
//`log("chargewait pfound" $ playerFound $ "Chargewait location" $ chargeLocation);

//`log(playerFound0
if (playerFound == false)
{
selfToPlayerLocation = theGame.P.Pawn.Location - self.Pawn.Location;
chargeLocation = selfToPlayerLocation;
playerFound = true;
}
else{
//selfToPlayer = self.spottedPawn.Location - self.Pawn.Location;
selfToPlayerLocation = theGame.P.Pawn.Location - self.Pawn.Location;
chargeLocation = selfToPlayerLocation;
DeltaRot = rotator(chargeLocation);
DeltaRot.Pitch = 0;

self.Pawn.FaceRotation(RInterpTo(self.Pawn.Rotatio n, rotator(selfToPlayerLocation), deltaTime, 10000, true), deltaTime);
if (chargeDelay > chargeDelayTime)
{
GotoState('Charge');
chargeDelay = 0;

Graylord
09-05-2011, 12:17 PM
I think your question is not clear(at least for me).

and then

for me slow cannon means for example it can rotate only 10 degree each second.
Am I right?(if so maybe I can help you)

Yes, that's the idea.

Those quotes are not conflicting, as one describes what I currently have, and the other describes what I want.

@Carsten
That's not exactly what I am looking for... I think. I'll have to take a closer look.

Carsten
09-05-2011, 12:24 PM
FaceRotation(RInterpTo(self.Pawn.Rotation, rotator(selfToPlayerLocation), deltaTime, 10000, true), deltaTime);

The bolded 10000 is rotation rate

Graylord
09-05-2011, 12:37 PM
RInterpTo does not give me the wanted behavior, it makes it rotate as if it's on a loose axis or something. (Appears like there's hardly any friction, which is the opposite of what I want). It particularily becomes a mess the pawn is rotated at the same time.

This is the setup I tried with InterpTo a while ago:

Controller.GetPlayerViewPoint( POVLoc, POVRot );

DesiredTorsoRotation.Yaw = POVRot.Yaw - Rotation.Yaw;
DesiredTorsoRotation.Pitch = 0;

TorsoRotationControl.BoneRotation = RInterpTo (TorsoRotationControl.BoneRotation,DesiredTorsoRot ation, DeltaTime, 2, False);

Also, note that I am not rotating the pawn, but a bone.

he3117
09-05-2011, 12:40 PM
How fast the torso can rotate?(Degree/second)

Graylord
09-05-2011, 01:03 PM
Your question is invalid, there is no rate. My rotations are not based on rates, but the raw input.

he3117
09-05-2011, 01:28 PM
So whats the meaning of low speed canon?Actually my question is valid.
Low speed canon means it can rotate only 10 degree/second.

Graylord
09-05-2011, 01:34 PM
he3117, you asked what the rotation rate is, and as I said there is none.
Hence why I am asking how to set it up in this particular case.

I know exactly what a rotation rate is.
You do not need a set rate to have motion.

he3117
09-05-2011, 01:48 PM
Ok.I thought you want to rotate a robot torso that I done that before.
good luck with your problem

Graylord
09-05-2011, 01:54 PM
I do want that, I think you are misunderstanding having and wanting.
I do not have a rotation rate, but I want a rotation rate.
I know how to setup a rotation rate, but I do not know how to setup a rotation rate based on set rotations.

he3117
09-05-2011, 02:30 PM
our solution was:



rotator MaxAngle,PotentialRot,DesireRot;

MaxAngle.Yaw=10*DeltaTime*DegToUnrRot;//only 10degree in 1 second
ClampRotation(PotentialRotation, Rotation,MaxAngle,MaxAngle);

DesireRotation=Rlerp(CurrentRotation,PotentialRota tion,DeltaTime,true);

Graylord
09-05-2011, 03:00 PM
How are you getting PotentialRotation (in what you are showing, it will just be 0,0,0 right?) and CurrentRotation?

Also, Rotation gives me the rotation of the pawn, which I cannot use, since I am only rotation the torso, not the pawn.

he3117
09-05-2011, 03:27 PM
oops!wrong code.



rotator MaxAngle,PotentialRot,DesireRot;

PotentialRotation=Rotation;
MaxAngle.Yaw=10*DeltaTime*DegToUnrRot;//only 10degree in 1 second
ClampRotation(PotentialRotation,TorsoRotation,MaxA ngle,MaxAngle);
DesireRotation=Rlerp(TorsoRotation,PotentialRotati on,DeltaTime,true);

rotation is where torso should go at last.For example controller rotation or camera rotation.

Graylord
09-05-2011, 03:58 PM
Hmm, no rotation is happening for me with that setup, can I ask you how your Degree into Unreal rotation conversion variable is done?

I don't mind just using the unreal rotation instead, which is about 1820 for 10 degrees.
So I just multiplied by that instead of 10 and dropped the conversion, but I suppose you may be doing something else there that I am missing?

he3117
09-05-2011, 05:56 PM
I'm using DegToUnrRot constant because Its easier to read and edit.
about your setting for rotation I think you should set PotentialRotation to:

(from your code)


Controller.GetPlayerViewPoint( POVLoc, POVRot );
PotentialRotattion=POVRot ;

But I'm not sure about your concept.

Graylord
09-06-2011, 03:03 AM
My concept of getting the rotation is;
Povrot is the rotation of the camera, and rotation is the rotation of the pawn.
I want the torso to rotate independently on the pawn, since I want to be aiming without rotating the pawn.
Normally, the pawn would add the rotation the root bone, which in turn will rotate the rest of the bones. However, by subtracting the pawns rotation, the torso will move without the pawn's influence.

I am only using yaw, since the pitch movement is handled by the arms, and not the torso.

This is the code currently:

Controller.GetPlayerViewPoint( POVLoc, POVRot );

PotentialRotation.Yaw = POVRot.Yaw - Rotation.Yaw;

MaxAngle.Yaw = 1820*DeltaTime;
ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MaxAngle);

DesiredTorsoRotation = Rlerp(TorsoRotationControl.BoneRotation,PotentialR otation, DeltaTime, True);

TorsoRotationControl.BoneRotation = DesiredTorsoRotation;

he3117
09-06-2011, 03:55 AM
Dose it work correctly?

Graylord
09-06-2011, 04:13 AM
No, it doesn't. :(

There is no movement. I know the povrot-rotation part is correct, as it worked before the clamping and lerping.
I think the problem is that the desired rotation and the torso rotation in my case is the same.

The rotation I want to apply the changes to is TorsoRotationControl.BoneRotation.
However, the current rotation of the torso is also TorsoRotationControl.BoneRotation.
I don't know what else I can use in either place.

he3117
09-06-2011, 04:28 AM
Maybe you should use relative rotation not absolute rotation.



local rotator rOffset;

roffset=CameraRotation-LastCameraRotation;

worldinfo.Game.broadCast(self,"rOffset"@roffset);//debug

potentialRotation=torsoRotation+rOffset;

worldinfo.Game.broadCast(self,"potentialRotation"@potentialRotation);//debug
MaxAngle.Yaw = 1820*DeltaTime;
ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MaxAngle);
worldinfo.Game.broadCast(self,"ClamppotentialRotation"@potentialRotation);//debug

DesiredTorsoRotation = Rlerp(TorsoRotationControl.BoneRotation,PotentialR otation, DeltaTime, True);
worldinfo.Game.broadCast(self,"DesiredTorsoRotation"@DesiredTorsoRotation);//debug

TorsoRotationControl.BoneRotation = DesiredTorsoRotation;
LastCameraRotation=CameraRotation;

Graylord
09-06-2011, 06:44 AM
Could you explain what you are doing here?

local rotator rOffset;

roffset=CameraRotation-LastCameraRotation;
CameraRotation and LastCameraRotation, gives me "invalid expression" errors, do you want me to just use the povrots here? Povrot is the rotation of the camera.

Also:

potentialRotation=torsoRotation+rOffset;

What is TorsoRotation supposed to be?

he3117
09-06-2011, 08:45 AM
first:


...
var rotator LastCameraRotation;

PostBeginPlay()
{
LastCameraRotation=CameraRotation;
//lastCameraRotation should be a global variable and cameraRotation is your current cameraRotation(Povrot)
}

then in tick or where you want to rotate your robot Torso you compare these two valuse.


local rotator rOffset;

roffset=CameraRotation-LastCameraRotation;//camera rotate for example 10 degree( from last tick) to left

potentialRotation=torsoRotation+rOffset;//torso rotation is currentTorso rotation in skeletallcontroll.
//so it should rotate 10 degree to left(rOffset) to match the currentRotation of camera

Graylord
09-06-2011, 09:08 AM
Ah, I see, now that makes sense. I'll try to work it in.

MonsOlympus
09-06-2011, 10:11 AM
Just curious if youve attempted anything from a different direction, I did make a suggestion in your other thread about a different approach. Or are you going to continue to bang your head against the wall and ignore everyone giving you advice? Only reason I suggest that is youre now using rOffset in here similar to how I delay the rotation. Perhaps you can post all of your code, I can suggest a fix for the entire thing all Ive gathered is bits from facing direction and update rotation, Im not even sure how you do your camera.

Graylord
09-06-2011, 10:43 AM
Oh, I haven't been ignoring any of you, there's just been a lot of misunderstanding.
I guess that's what you get when you bring semi-self-thought people together who use different methods and wording.

Since you requested it, here's all of my camera and pawn control related codes without any of the experimental coding:
PlayerController:



//Update player rotation when walking
state PlayerWalking
{
ignores SeePlayer, HearNoise, Bump;


function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
{
local Vector tempAccel;
local Rotator CameraRotationYawOnly;


if( Pawn == None )
{
return;
}

if (Role == ROLE_Authority)
{
// Update ViewPitch for remote clients
Pawn.SetRemoteViewPitch( Rotation.Pitch );
}

tempAccel.Y = PlayerInput.aStrafe * DeltaTime * 100 * PlayerInput.MoveForwardSpeed;
tempAccel.X = PlayerInput.aForward * DeltaTime * 100 * PlayerInput.MoveForwardSpeed;
tempAccel.Z = 0; //no vertical movement for now, may be needed by ladders later

//get the controller yaw to transform our movement-accelerations by
CameraRotationYawOnly.Yaw = Rotation.Yaw;
tempAccel = tempAccel>>CameraRotationYawOnly; //transform the input by the camera World orientation so that it's in World frame
Pawn.Acceleration = tempAccel;

Pawn.FaceRotation(Rotation,DeltaTime); //notify pawn of rotation
CheckJumpOrDuck();

}
}
State Dead
{
function FindGoodView()
{
`log ("FindGoodView");
}
}

//Controller rotates with turning input
function UpdateRotation( float DeltaTime )
{
local Rotator DeltaRot, newRotation, ViewRotation;

ViewRotation = Rotation;

if (Pawn!=none)
{
Pawn.SetDesiredRotation(ViewRotation);
}

// Calculate Delta to be applied on ViewRotation
DeltaRot.Yaw = PlayerInput.aTurn;
DeltaRot.Pitch = PlayerInput.aLookUp;

ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
SetRotation(ViewRotation);

NewRotation = ViewRotation;
NewRotation.Roll = Rotation.Roll;

if ( Pawn != None )
Pawn.FaceRotation(NewRotation, deltatime); //notify pawn of rotation
}




DefaultProperties
{
}

Pawn:


var float CamOffsetDistance; //distance to offset the camera from the player in unreal units
var float CamMinDistance, CamMaxDistance;
var float CamZoomTick; //how far to zoom in/out per command
var float CamHeight; //how high cam is relative to pawn pelvis
var float CamColDistance; //How far away from the wall the camera will be
var Rotator TorsoRotation;
var bool CameraMode;
var soundcue EnergyFireSound;
var bool bPawnIsDead;

var SkelControlSingleBone TorsoRotationControl;
var SkelControlSingleBone ArmRotationControl;
var SkelControlSingleBone UnderArmRotationControl;

var Rotator DesiredPawnRotation;

var float RotationSmoothing;


/** Max distance from listener to play footstep sounds */
var float MaxFootstepDistSq;

simulated event PostBeginPlay()
{
TorsoRotationControl = SkelControlSingleBone(Mesh.FindSkelControl('TorsoR otationController'));
ArmRotationControl = SkelControlSingleBone(Mesh.FindSkelControl('ArmRot ationController'));
UnderArmRotationControl = SkelControlSingleBone(Mesh.FindSkelControl('UnderA rmRotationController'));
EnergyFireSound = SoundCue'A_Vehicle_Manta.SoundCues.A_Vehicle_Manta _Fire';
super.PostBeginPlay();
`Log("Custom Pawn up"); //debug

}





simulated function FaceRotation(rotator NewRotation, float DeltaTime)
{

local float DesiredAlpha;
// Do not update Pawn's rotation if no accel
if (Normal(Acceleration)!=vect(0,0,0))
{

//Only apply rotation when walking
if ( (Physics == PHYS_Walking) )
{
//set the rotation to the acceleration
DesiredPawnRotation = rotator((Location + Normal(Acceleration))-Location);
DesiredPawnRotation.Pitch = 0;
}

DesiredAlpha = DeltaTime/RotationSmoothing;
NewRotation = RLerp(Rotation,DesiredPawnRotation,DesiredAlpha,tr ue);
//apply rotation
SetRotation(NewRotation);

}

}


//orbit cam, follows player controller rotation
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
local vector HitLoc,HitNorm, End, Start, vecCamHeight, vecWallDistance;
if( bPawnIsDead == false)
{
vecCamHeight = vect(0,0,0);
vecCamHeight.Z = CamHeight;
vecWallDistance.Z = CamColDistance;
Start = Location;
End = (Location+vecCamHeight)-(Vector(Controller.Rotation) * CamOffsetDistance); //cam follow behind player controller
out_CamLoc = End;

//trace to check if cam running into wall/floor
if(Trace(HitLoc,HitNorm,End,Start,false,vect(12,12 ,12))!=none)
{
out_CamLoc = HitLoc + vecWallDistance;
}

//camera will look slightly above player
out_CamRot=rotator((Location + vecCamHeight) - out_CamLoc);
return true;
}
else
Super.CalcCamera(fDeltaTime,out_CamLoc,out_CamRot, out_FOV );
}

exec function CamZoomIn()
{
`Log("Zoom in");
if(CamOffsetDistance > CamMinDistance)
CamOffsetDistance-=CamZoomTick;
}

exec function CamZoomOut()
{
`Log("Zoom out");
if(CamOffsetDistance < CamMaxDistance)
CamOffsetDistance+=CamZoomTick;
}

exec function CameraModeToggle()
{
CameraMode = !CameraMode;
}

simulated event Tick(float DeltaTime)
{
local Vector POVLoc;
local Rotator POVRot;


if (CameraMode == False)
{

Controller.GetPlayerViewPoint( POVLoc, POVRot );

PotentialRotation.Yaw = POVRot.Yaw - Rotation.Yaw;

TorsoRotationControl.BoneRotation.Yaw = POVRot.Yaw - Rotation.Yaw;

if ( Povrot.Pitch >= 0)
{

ArmRotationControl.BoneRotation.Pitch = -Abs(POVRot.Pitch)/3;
UnderArmRotationControl.BoneRotation.Pitch = -Abs(POVRot.Pitch)/1.5;
}

else
{
UnderArmRotationControl.BoneRotation.Pitch = Abs(POVRot.Pitch);
}
}
}




defaultproperties
{
Begin Object class=SkeletalMeshComponent Name=SkeletalMeshComponent0
SkeletalMesh=SkeletalMesh'Character.Mech_Skeleton'
PhysicsAsset=PhysicsAsset'Character.Mech_Skeleton_ Physics'
AnimTreeTemplate=AnimTree'Character.Mech_AnimTree'
AnimSets(0)=AnimSet'Character.Mech_Animset'

bHasPhysicsAssetInstance=True
bEnableSoftBodySimulation=True
bSoftBodyAwakeOnStartup=True
bEnableFullAnimWeightBodies=True

End Object
Mesh=SkeletalMeshComponent0
Components.Add(SkeletalMeshComponent0)

Begin Object Name=CollisionCylinder
CollisionRadius=+0175.000000
CollisionHeight=+0325.000000
End Object
CylinderComponent=CollisionCylinder

BlockRigidBody=True
//Camera Properties
CamHeight = 330.0
CamMinDistance = 200.0
CamMaxDistance = 3000.0
CamOffsetDistance=750.0
CamZoomTick=50.0
CamColDistance = 20.0

AccelRate=+00512.000000
DesiredSpeed=+00001.000000
MaxDesiredSpeed=+00001.000000
MaxFallSpeed=+1200.0
AIMaxFallSpeedFactor=1.0
NonPreferredVehiclePathMultiplier=1.0

AirSpeed=+00600.000000
GroundSpeed=+00600.000000
JumpZ=+00420.000000
OutofWaterZ=+420.0
LadderSpeed=+200.0
WaterSpeed=+00300.000000

bJumpCapable = False

CameraMode=False
bPawnIsDead=False

RotationSmoothing = 2

}

I do suspect I have been going at it in an overly complicated fashion, but I haven't been able to think of any other way.

Edit: @he3117: So, I have now worked that in, but there's still no changes. Which is weird, since I can see the numbers in the debug, and the DesiredTorsoRotation is being added to the bone, but the bone does not rotate. I even added a debug for the rotation of the bone itself, and the numbers are being sent there correctly. But for some unfatomable reason, it doesn't rotate, even though everything is telling me it should.

I tried removing all the changes, to make sure I hadn't mucked up somewhere else, but then the bone would control fine once again.

MonsOlympus
09-06-2011, 02:55 PM
Thats much more helpful, I assumed your camera was using controller.rotation but I just had to be sure. I know my wording isnt the best but I much prefer for people to understand the english version than to just hand off code because even snippets leave alot to interpretation.

Now what Im curious about at this point is if you have actually had the pawn facing a different direction to the player controller's rotation at all or if only modifying the player controllers rotation compared to the input is giving results. Does that make sense?

What I can see is in your ProcessMove function you set the CameraRotationYaw directly from the PlayerInput, you then set the Camera behind the Pawn in the Pawn class via the Controllers.Rotation. Now this means no matter which direction the Pawn is facing in relation to the Controller, the camera is fixed at that calculated location.

What Ive understood is you want the Pawn to lag behind the Input/Camera and continually move towards a DesiredRotation. Take the CameraRotation and Pawn.Rotation (not to be confused with Controller.Rotation) and just... add a fraction of the difference in FaceRotation. For a Lerp or RLerp in the way you described what you would like to me, you have a min/max Speeds, you move the maximum speed between a range so you have min-SpeedMax, max-SpeedMax; min-SpeedMax cannot be less than SpeedMin.

Now you can ease-in/out of your facing rotation, the issue is when the Controller.Rotation updates mid cycle. You might ask me why Im not using RLerp or Lerp but I question the motives behind using any function call or assignment in a function called every tick including native functions. Whilst the benefits of using inbuilt math functions is there you never know what they are really doing without documentation and I simply cant rely on the output of RLerp without running it through a test suite. Its easier for me to explain how it functions and also save memory to write a similar functionality specifically suited to the guidelines you gave me. For instance, you might use a float for interpolation but a rotation is always rounded back to an int 3 vector so you end up with wastage especially in the case of using only 2 rotational axis which are only ints not 3 floats.

Graylord
09-06-2011, 06:45 PM
Now what Im curious about at this point is if you have actually had the pawn facing a different direction to the player controller's rotation at all or if only modifying the player controllers rotation compared to the input is giving results. Does that make sense?

I'm afraid I am not sure what you are asking.
If you want to know if the setup I am currently using is having an effect, then yes.


What I can see is in your ProcessMove function you set the CameraRotationYaw directly from the PlayerInput, you then set the Camera behind the Pawn in the Pawn class via the Controllers.Rotation. Now this means no matter which direction the Pawn is facing in relation to the Controller, the camera is fixed at that calculated location.

Correct, it is also the intended and wanted behaviour of the camera.



What Ive understood is you want the Pawn to lag behind the Input/Camera and continually move towards a DesiredRotation. Take the CameraRotation and Pawn.Rotation (not to be confused with Controller.Rotation) and just... add a fraction of the difference in FaceRotation. For a Lerp or RLerp in the way you described what you would like to me, you have a min/max Speeds, you move the maximum speed between a range so you have min-SpeedMax, max-SpeedMax; min-SpeedMax cannot be less than SpeedMin.


Actually, The pawns behaviour is just fine the way it is, the lerping handled the "lag" in a fashion that was pretty much what I wanted.
What I am trying to control now is the rotation of the pawn's torso bone.



Now you can ease-in/out of your facing rotation, the issue is when the Controller.Rotation updates mid cycle. You might ask me why Im not using RLerp or Lerp but I question the motives behind using any function call or assignment in a function called every tick including native functions. Whilst the benefits of using inbuilt math functions is there you never know what they are really doing without documentation and I simply cant rely on the output of RLerp without running it through a test suite. Its easier for me to explain how it functions and also save memory to write a similar functionality specifically suited to the guidelines you gave me. For instance, you might use a float for interpolation but a rotation is always rounded back to an int 3 vector so you end up with wastage especially in the case of using only 2 rotational axis which are only ints not 3 floats.
Fair enough, though I've noticed that there's some useful built in functions in rlerp which I believe could be a hassle to write, at least the first time. Such as automatically turning towards the shortest route towards the target, instead of just continiously rotating the same way.

MonsOlympus
09-07-2011, 01:16 AM
Actually with unreal rotations thats one of the easiest things to write especially in functions with delta available. Shortest route is go figure, the smallest difference between rotations so its simply acouple of conditionals hell even a conditional operator if you like fluff.

he3117
09-07-2011, 02:41 AM
I have now worked that in, but there's still no changes. Which is weird, since I can see the numbers in the debug, and the DesiredTorsoRotation is being added to the bone, but the bone does not rotate

I think you should double check AnimTree settings.write a test function and in that add some value to bone rotation to see if its work.and call it from timer or exec function

Graylord
09-07-2011, 03:33 AM
As I said, If I just apply the rotations directly, it works fine. But if I rotate it through the codes you have provided, it doesn't.

Graylord
09-07-2011, 06:32 AM
local Vector POVLoc;
local Rotator POVRot, PotentialRotation, DesiredTorsoRotation, MaxAngle, MinAngle;
local int rOffset;

//Getting the Camera angle.
Controller.GetPlayerViewPoint( POVLoc, POVRot );

//Subtracting the current camera angle, with the previous camera angle in order to get the difference.
rOffset=(POVRot.Yaw - Rotation.Yaw)-LastCameraRotation.Yaw;
worldinfo.Game.broadCast(self,"rOffset"@roffset);//debug

//Adding the modifications of the camera angle to the bone, to get the ultimate rotation.
PotentialRotation.Yaw=TorsoRotationControl.BoneRot ation.Yaw+rOffset;
worldinfo.Game.broadCast(self,"potentialRotation"@potentialRotation);//debug

//Calculating the max and min amount of rotation per second.
MaxAngle.Yaw = 1820*DeltaTime;
MinAngle.Yaw = 182*DeltaTime;

//Clamping the rotations speed, out rotation, base rotation and the max-min angles per second.
ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MinAngle);
worldinfo.Game.broadCast(self,"ClamppotentialRotation"@potentialRotation);//debug

//Rlerps the bone's rotation with the clamped rotation to give a smooth transition.
DesiredTorsoRotation = Rlerp(TorsoRotationControl.BoneRotation,PotentialR otation, DeltaTime, True);
worldinfo.Game.broadCast(self,"DesiredTorsoRotation"@DesiredTorsoRotation);//debug

//Finally adds the rotation to the bone.
TorsoRotationControl.BoneRotation = DesiredTorsoRotation;
worldinfo.Game.broadCast(self,"TorsoBoneRotation"@TorsoRotationControl.BoneRotation);//debug

//Updates the previous camera rotation for the next Check.
LastCameraRotation.Yaw=POVRot.Yaw - Rotation.Yaw;

So, this is my updated tick. I noticed all the debug numbers are always the same except for the offset, and their increase with the movement of the mouse is very little, like 5 per full rotation of the camera.

I tried to keep rotating to see if there was a miscalculation somewhere that makes the rotations just un-noticably small, but even after 1200, which should be clearly visible, there was still no rotation.

he3117
09-07-2011, 06:48 AM
I notice this in your code:
//Calculating the max and min amount of rotation per second.
MaxAngle.Yaw = 1820*DeltaTime;
MinAngle.Yaw = 182*DeltaTime;

clamprotation dos'nt work correctly because min angel is too small

it should be


ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MaxAngle);//use max angle for min and Max

Graylord
09-07-2011, 07:02 AM
Oh, that was just a test, since I don't want the minimum and maximum speed to be the same. If the player rotates the camera at a speed lower than the maximum speed, I don't want it to rotate faster than the camera's rotation. Besides, 1 degree per second should still be plenty visible.

It is the same result with max angle as the minimum angle.

Maybe you'll see what's going on if you see the numbers, so I'll upload a video shortly.

he3117
09-07-2011, 07:13 AM
MaxAngle and MinAngle dosnt mean rotation speed.MaxAngle mean max allowable Angle for turning right and min angle mean MAX allowable angle for turning left.

Graylord
09-07-2011, 07:17 AM
Aaah, I see. Shouldn't the min-angle be negative then?

Either, way, it will take some time for the video to upload, I'll reply when it's done.

he3117
09-07-2011, 07:19 AM
No.it should be positive.

ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MaxAngle);//use max angle for min and Max

Graylord
09-07-2011, 09:34 AM
http://www.youtube.com/watch?v=5zc9osw0nM0

You should be able to see the numbers clearly if you use 720p and go fullscreen.

The reason the numbers decrease less when rotating in the negative direction was the previous min-rotation problem, but that has been fixed.

he3117
09-07-2011, 11:05 AM
It seams roffset should be a global value and use a bigger speed value like 90 degree to see if its really work.


rOffset+=(POVRot.Yaw - Rotation.Yaw)-LastCameraRotation.Yaw;

Graylord
09-07-2011, 12:06 PM
Alright, now with these changes we finally have movement.
However, the speed is incredibly slow even though I increased it to 16384, which should be 90 degrees, more or less.
It also turns the wrong direction it seems.

I think the problem could be with the Rotation*Deltatime. I am still curious what kind of numbers you are getting with the Degree to Unreal Rotation conversion.

he3117
09-07-2011, 12:18 PM
test this:


local Vector POVLoc;
local Rotator POVRot, PotentialRotation, DesiredTorsoRotation, MaxAngle, MinAngle;


//Getting the Camera angle.
Controller.GetPlayerViewPoint( POVLoc, POVRot );

//Subtracting the current camera angle, with the previous camera angle in order to get the difference.
rOffset+=(POVRot.Yaw - Rotation.Yaw)-LastCameraRotation.Yaw;
worldinfo.Game.broadCast(self,"rOffset"@roffset);//debug

//Adding the modifications of the camera angle to the bone, to get the ultimate rotation.
PotentialRotation.Yaw=TorsoRotationControl.BoneRot ation.Yaw+rOffset;
worldinfo.Game.broadCast(self,"potentialRotation"@potentialRotation);//debug

//Calculating the max and min amount of rotation per second.
MaxAngle.Yaw = 1820*DeltaTime;


worldinfo.Game.broadCast(self,"ClamppotentialRotation"@potentialRotation);//debug

//Rlerps the bone's rotation with the clamped rotation to give a smooth transition.
DesiredTorsoRotation = Rlerp(TorsoRotationControl.BoneRotation,PotentialR otation, DeltaTime, True);
worldinfo.Game.broadCast(self,"DesiredTorsoRotation"@DesiredTorsoRotation);//debug

//Clamping the rotations speed, out rotation, base rotation and the max-min angles per second.
ClampRotation(DesiredTorsoRotation,TorsoRotationCo ntrol.BoneRotation, MaxAngle, MaxAngle);


//Finally adds the rotation to the bone.
TorsoRotationControl.BoneRotation = DesiredTorsoRotation;
worldinfo.Game.broadCast(self,"TorsoBoneRotation"@TorsoRotationControl.BoneRotation);//debug

//Updates the previous camera rotation for the next Check.
LastCameraRotation.Yaw=POVRot.Yaw - Rotation.Yaw;

first lerp then clamp it.

Graylord
09-07-2011, 12:28 PM
Exactly the same I am afraid.

Seeing as it appears to always rotate the opposite way of what it should, I would guess there's a mathematical error somewhere.
A multiplication where there should be division, or something similar.

Edit: I don't think adding offset was right, now it will never reset and continiously rotate.

he3117
09-07-2011, 12:49 PM
you right you should update roffset with desirreRotation value;

roffset-=desireRotation.Yaw;

Graylord
09-07-2011, 01:49 PM
You mean like this?

//Getting the Camera angle.
Controller.GetPlayerViewPoint( POVLoc, POVRot );

//Subtracting the current camera angle, with the previous camera angle in order to get the difference.
rOffset+=(POVRot.Yaw - Rotation.Yaw)-LastCameraRotation.Yaw;
worldinfo.Game.broadCast(self,"rOffset"@roffset);//debug

//Adding the modifications of the camera angle to the bone, to get the ultimate rotation.
PotentialRotation.Yaw=TorsoRotationControl.BoneRot ation.Yaw+rOffset;
worldinfo.Game.broadCast(self,"potentialRotation"@potentialRotation);//debug

//Calculating the max and min amount of rotation per second.
MaxAngle.Yaw = 16384*DeltaTime;

//Clamping the rotations speed, out rotation, base rotation and the max-min angles per second.
ClampRotation(PotentialRotation,TorsoRotationContr ol.BoneRotation, MaxAngle, MaxAngle);
worldinfo.Game.broadCast(self,"ClamppotentialRotation"@potentialRotation);//debug

//Rlerps the bone's rotation with the clamped rotation to give a smooth transition.
DesiredTorsoRotation = Rlerp(TorsoRotationControl.BoneRotation,PotentialR otation, DeltaTime, True);
worldinfo.Game.broadCast(self,"DesiredTorsoRotation"@DesiredTorsoRotation);//debug

//Finally adds the rotation to the bone.
TorsoRotationControl.BoneRotation = DesiredTorsoRotation;
worldinfo.Game.broadCast(self,"TorsoRotationControl.BoneRotation"@TorsoRotationControl.BoneRotation);//debug

//Updates the previous camera rotation for the next Check.
LastCameraRotation.Yaw=POVRot.Yaw - Rotation.Yaw;
roffset-=DesiredTorsoRotation.Yaw;

That makes it just jitter. :(

Graylord
09-08-2011, 03:51 AM
Or did you have something else in mind?