hello
heres a very simple 'aeroplane' script.
'D' and 'A' - Thrust
Arrows or Mouse - Steer/Pitch
Tegleg_PlaneController.uc
Tegleg_PlanePawn.ucCode:class Tegleg_PlaneController extends UTPlayerController; var float Thrust; var Rotator ViewRotation; simulated function PostBeginPlay() { Super.PostBeginPlay(); SetCameraMode('ThirdPerson'); } state PlayerWalking { ignores SeePlayer, HearNoise, Bump; function PlayerMove(float DeltaTime) { local vector X,Y,Z; //`Log("!!!controller state WALKING : playermove !!!!!!!!!!!!!!!!!!!!!!!!"); GetAxes(Rotation,X,Y,Z); //forward thrust Pawn.Acceleration = Thrust*X; Pawn.Acceleration = Pawn.AccelRate * Normal(Pawn.Acceleration); // Update rotation. UpdateRotation( DeltaTime ); if ( Role < ROLE_Authority ) // then save this move and replicate it ReplicateMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0)); else ProcessMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0)); } event BeginState(Name PreviousStateName) { Pawn.SetPhysics(PHYS_Flying); } } //flight code/////////////////////////// function UpdateRotation( float DeltaTime ) { local Rotator TempRotationP, TempRotationRoll, TempWorldRotationRoll; ViewRotation = Rotation; if (Pawn != None) { Pawn.SetDesiredRotation(ViewRotation); } //forward thrust if ((PlayerInput.aStrafe > 0) && (Thrust < 5000)) {Thrust += 50;} if ((PlayerInput.aStrafe < 0) && (Thrust > 0)) {Thrust -= 50;} /////// ROTATION //////////////// //Roll if (PlayerInput.aTurn > 0) { ViewRotation.Yaw += 100; TempWorldRotationRoll = WorldInfo.Rotation; TempWorldRotationRoll.Roll += 10000; TempRotationRoll = RInterpTo(Rotation, TempWorldRotationRoll, DeltaTime, 1.0); ViewRotation.Roll = TempRotationRoll.Roll; } if (PlayerInput.aTurn < 0) { ViewRotation.Yaw -= 100; TempWorldRotationRoll = WorldInfo.Rotation; TempWorldRotationRoll.Roll -= 10000; TempRotationRoll = RInterpTo(Rotation, TempWorldRotationRoll, DeltaTime, 1.0); ViewRotation.Roll = TempRotationRoll.Roll; } //level out roll when no turn input if (PlayerInput.aTurn == 0) { if(ViewRotation.Roll != 0) ViewRotation.Roll = Lerp(ViewRotation.Roll, 0.0, 0.01); } //Pitch if (PlayerInput.aForward > 0 || PlayerInput.aLookUp < 0) {ViewRotation.Pitch -= 100;} if (PlayerInput.aForward < 0 || PlayerInput.aLookUp > 0) {ViewRotation.Pitch += 100;} //level out pitch when no pitch input if (PlayerInput.aForward == 0 && PlayerInput.aLookUp == 0) { TempRotationP = RInterpTo(Rotation, WorldInfo.Rotation, DeltaTime, 1.0); ViewRotation.Pitch = TempRotationP.Pitch; } SetRotation(ViewRotation); if (Pawn != None) { Pawn.FaceRotation(ViewRotation, DeltaTime); Pawn.SetDesiredRotation(ViewRotation); Pawn.Mesh.SetRBRotation(ViewRotation); } }
heres a gametype that uses this pawn and controllerCode:class Tegleg_PlanePawn extends UTPawn; simulated function PostBeginPlay() { Super.PostBeginPlay(); StartFlying(); if(Mesh.PhysicsAssetInstance != None) { // Now set up the physics based on what we are currently doing. if(Physics != PHYS_Flying) { SetPhysics(PHYS_Flying); } } SetThirdPersonCamera(True); } simulated function FaceRotation(rotator NewRotation, float DeltaTime) { SetRotation(NewRotation); } simulated singular event Rotator GetBaseAimRotation() { Return Rotation; } function SetMovementPhysics() { if (Physics != PHYS_Flying) { SetPhysics(PHYS_Flying); } } simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) { local vector X, Y, Z; GetAxes(Rotation, X, Y, Z); //set the cam location and rotation out_CamLoc = Location - 200 * X; out_CamRot = Rotation; return true; } defaultproperties { // Flags bCanBeDamaged=true bCanCrouch=false bCanFly=true bCanJump=false bCanSwim=false bCanTeleport=true bCanWalk=false bJumpCapable=false bProjTarget=true bSimulateGravity=false bShouldBaseAtStartup=true GroundSpeed=5000 AirSpeed=6000 }
TeglegGame_Plane.uc
Have Fun!Code:class TeglegGame_Plane extends UTGame; static event class<GameInfo> SetGameType(string MapName, string Options, string Portal) { return default.class; } defaultproperties { PlayerControllerClass=class'Tegleg_PlaneController ' DefaultPawnClass=class'Tegleg_PlanePawn' }
there will be no updates or fixes, thats up to you.
feel free to ask questions if theres something you dont understand.




Reply With Quote




Bookmarks