The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
Legacy:Vehicles/Driver Setup Alternative
Alternative Vehicle Driver Setup----
By Agent Scully----
This is an alternate method of how to modify the player bones so that they do not need replication for online play, just two functions. One called:
simulated function AttachDriver(Pawn P)
And a second one called:
simulated function DetachDriver(Pawn P)
These two simulated functions will obviously, do as it says. Attach the driver to the vehicle and set the bones in place when the player gets on the bike, and detach the driver and set the bones to normal rotation. Let's take a look at how they work:
First of all you need var rotators at the top of your code. This tells your script that you'll be using rotators in AttachDriver for each bone.
var rotator PelvisDrive; var rotator NeckDrive; var rotator SpineDrive,SpineDrive1,SpineDrive2; var rotator ArmDriveL,ArmDriveR; var rotator ForeArmDriveL,ForeArmDriveR; var rotator LeftHandDriveL,RightHandDriveR; var rotator LFingerDrive0,LFingerDrive01,LFingerDrive02; var rotator RFingerDrive0,RFingerDrive01,RFingerDrive02; var rotator ThighDriveL,ThighDriveR; var rotator CalfDriveL,CalfDriveR; var rotator FootDriveL,FootDriveR;
So then we move onto our AttachDriver and DetachDriver:
// added for driver position resetting simulated function AttachDriver(Pawn P) { super.AttachDriver(P); // Pelvis -------------------------------------------------- PelvisDrive.Yaw=8192; P.SetBoneRotation('Bip01 Pelvis',PelvisDrive); // Head ---------------------------------------------------- NeckDrive.Yaw=-10000; P.SetBoneRotation('Bip01 Head',NeckDrive); // Spine --------------------------------------------------- SpineDrive.Yaw=2048; P.SetBoneRotation('Bip01 Spine',SpineDrive); //Spine 1 SpineDrive1.Yaw=2048; P.SetBoneRotation('Bip01 Spine1',SpineDrive1); //Spine 2 SpineDrive2.Yaw=2048; P.SetBoneRotation('Bip01 Spine2',SpineDrive2); // Arms ---------------------------------------------------- //LeftArm ArmDriveL.Pitch=-4696; ArmDriveL.Yaw=-10000; ArmDriveL.Roll=6000; P.SetBoneRotation('Bip01 L UpperArm',ArmDriveL); //RightArm ArmDriveR.Pitch=4696; ArmDriveR.Yaw=-11000; ArmDriveR.Roll=-6000; P.SetBoneRotation('Bip01 R UpperArm',ArmDriveR); //Left ForeArm ForeArmDriveL.Yaw=-8010; P.SetBoneRotation('Bip01 L ForeArm',ForeArmDriveL); //Right ForeArm ForeArmDriveR.Yaw=-6000; P.SetBoneRotation('Bip01 R ForeArm',ForeArmDriveR); //Left Hand LeftHandDriveL.Pitch=6000; LeftHandDriveL.Roll=-16384; P.SetBoneRotation('Bip01 L Hand',LeftHandDriveL); //Right Hand RightHandDriveR.Pitch=5000; RightHandDriveR.Roll=-16384; P.SetBoneRotation('Bip01 R Hand',RightHandDriveR); // Fingers ------------------------------------------------- //LFinger0 LFingerDrive0.Yaw=-10000; P.SetBoneRotation('Bip01 L Finger0',LFingerDrive0); //LFinger1 LFingerDrive01.Yaw=-10000; P.SetBoneRotation('Bip01 L Finger01',LFingerDrive01); //LFinger2 LFingerDrive02.Yaw=-10000; P.SetBoneRotation('Bip01 L Finger02',LFingerDrive02); //RFinger0 LFingerDrive0.Yaw=-10000; P.SetBoneRotation('Bip01 R Finger0',RFingerDrive0); //RFinger1 LFingerDrive01.Yaw=-10000; P.SetBoneRotation('Bip01 R Finger01',RFingerDrive01); //RFinger2 LFingerDrive02.Yaw=-10000; P.SetBoneRotation('Bip01 R Finger02',RFingerDrive02); // Legs ---------------------------------------------------- //Left Thigh ThighDriveL.Pitch=5600; ThighDriveL.Yaw=-1000; ThighDriveL.Roll=3200; P.SetBoneRotation('Bip01 L Thigh',ThighDriveL); //Right Thigh ThighDriveR.Pitch=-5600; ThighDriveR.Yaw=-1000; ThighDriveR.Roll=-3200; P.SetBoneRotation('Bip01 R Thigh',ThighDriveR); //Left Calf CalfDriveL.Yaw=-10000; CalfDriveL.Roll=-8000; P.SetBoneRotation('Bip01 L Calf',CalfDriveL); //RightCalf CalfDriveR.Yaw=-10000; CalfDriveR.Roll=8000; P.SetBoneRotation('Bip01 R Calf',CalfDriveR); //Left Foot FootDriveL.Pitch=-9000; FootDriveL.Yaw=15000; P.SetBoneRotation('Bip01 L Foot',FootDriveL); //Right Foot FootDriveR.Pitch=9000; FootDriveR.Yaw=15000; P.SetBoneRotation('Bip01 R Foot',FootDriveR); }
The (PawnP) tells the engine to rotate a pawn, in this case the player. The result for this particular bone rotation is something like this:
Now we have the engine reset everything once the player leaves the bike, or else he'll be all twisted up:
simulated function DetachDriver(Pawn P) { // After the player leaves the vehicle, resets its additional bone rotations or else he'll be all twisted // Simply resets everything // Pelvis -------------------------------------------------- Driver.SetBoneRotation('Bip01 Pelvis'); // Head ---------------------------------------------------- Driver.SetBoneRotation('Bip01 Head'); // Spine --------------------------------------------------- Driver.SetBoneRotation('Bip01 Spine'); Driver.SetBoneRotation('Bip01 Spine1'); Driver.SetBoneRotation('Bip01 Spine2'); // Arms ---------------------------------------------------- Driver.SetBoneRotation('Bip01 L UpperArm'); Driver.SetBoneRotation('Bip01 R UpperArm'); Driver.SetBoneRotation('Bip01 L ForeArm'); Driver.SetBoneRotation('Bip01 R ForeArm'); Driver.SetBoneRotation('Bip01 L Hand'); Driver.SetBoneRotation('Bip01 R Hand'); // Fingers ------------------------------------------------- Driver.SetBoneRotation('Bip01 L Finger0'); Driver.SetBoneRotation('Bip01 L Finger01'); Driver.SetBoneRotation('Bip01 L Finger02'); Driver.SetBoneRotation('Bip01 R Finger0'); Driver.SetBoneRotation('Bip01 R Finger01'); Driver.SetBoneRotation('Bip01 R Finger02'); // Legs ------------------------------------roll--Pitch--Yaw------------ Driver.SetBoneRotation('Bip01 L Thigh'); Driver.SetBoneRotation('Bip01 L Thigh'); Driver.SetBoneRotation('Bip01 L Calf'); Driver.SetBoneRotation('Bip01 R Calf'); Driver.SetBoneRotation('Bip01 L Foot'); Driver.SetBoneRotation('Bip01 R Foot'); }
This sets the driver back to the way he was before you got on the hoverbike. More simple than the other code, and no online replication or tick function needed. Enjoy :)