Here's the code for a character that moves in 8 ways, facing the direction you press, and also the isometric camera (Which is copied from UDN docs)
Sorry if this has been covered somewhere else, haven't been on here in a while.
PawnClass
Code:
class Mod2Pawn extends UTPawn; var float CamOffsetDistance; //distance to offset the camera from the player var int IsoCamAngle; //pitch angle of the camera //override to make player mesh visible by default simulated event BecomeViewTarget( PlayerController PC ) { local UTPlayerController UTPC; Super.BecomeViewTarget(PC); if (LocalPlayer(PC.Player) != None) { UTPC = UTPlayerController(PC); if (UTPC != None) { //set player controller to behind view and make mesh visible UTPC.SetBehindView(true); SetMeshVisibility(UTPC.bBehindView); UTPC.bNoCrosshair = true; } } } simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) { out_CamLoc = Location; out_CamLoc.X -= Cos(IsoCamAngle * UnrRotToRad) * CamOffsetDistance; out_CamLoc.Z += Sin(IsoCamAngle * UnrRotToRad) * CamOffsetDistance; out_CamRot.Pitch = -1 * IsoCamAngle; out_CamRot.Yaw = 0; out_CamRot.Roll = 0; return true; } simulated singular event Rotator GetBaseAimRotation() { local rotator POVRot, tempRot; tempRot = Rotation; tempRot.Pitch = 0; SetRotation(tempRot); POVRot = Rotation; POVRot.Pitch = 0; return POVRot; } defaultproperties { IsoCamAngle=6420 //35.264 degrees CamOffsetDistance=384.0 }
Code:
class Mod2PlayerController extends UTPlayerController; state PlayerWalking { ignores SeePlayer, HearNoise, Bump; event NotifyPhysicsVolumeChange( PhysicsVolume NewVolume ) { if ( NewVolume.bWaterVolume && Pawn.bCollideWorld ) { GotoState(Pawn.WaterMovementState); } } function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot) { if( Pawn == None ) { return; } if (Role == ROLE_Authority) { // Update ViewPitch for remote clients Pawn.SetRemoteViewPitch( Rotation.Pitch ); } Pawn.Acceleration = NewAccel; CheckJumpOrDuck(); } function PlayerMove( float DeltaTime ) { local vector X,Y,Z, NewAccel; local eDoubleClickDir DoubleClickMove; local bool bSaveJump; local Rotator DeltaRot, ViewRotation, OldRot, NewRot;; if( Pawn == None ) { GotoState('Dead'); } else { GetAxes(Rotation,X,Y,Z); //update viewrotation ViewRotation = Rotation; // Calculate Delta to be applied on ViewRotation ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot ); SetRotation(ViewRotation); // Update acceleration. NewAccel = PlayerInput.aForward*X + PlayerInput.aStrafe*Y; NewAccel.Z = 0; // pawn face newaccel direction // OldRot = Pawn.Rotation; if( Pawn != None ) { if( NewAccel.X > 0.0 || NewAccel.X < 0.0 || NewAccel.Y > 0.0 || NewAccel.Y < 0.0 ) NewRot = Rotator(NewAccel); else NewRot = Pawn.Rotation; } Pawn.FaceRotation(RInterpTo(OldRot,NewRot,Deltatime,90000,true),Deltatime); NewAccel = Pawn.AccelRate * Normal(NewAccel); DoubleClickMove = PlayerInput.CheckForDoubleClickMove( DeltaTime/WorldInfo.TimeDilation ); bDoubleJump=false; if( bPressedJump && Pawn.CannotJumpNow() ) { bSaveJump = true; bPressedJump = false; } else { bSaveJump = false; } ProcessMove(DeltaTime, NewAccel, DoubleClickMove,Rotation); bPressedJump = bSaveJump; } } event BeginState(Name PreviousStateName) { DoubleClickDir = DCLICK_None; bPressedJump = false; GroundPitch = 0; if ( Pawn != None ) { Pawn.ShouldCrouch(false); if (Pawn.Physics != PHYS_Falling && Pawn.Physics != PHYS_RigidBody) // FIXME HACK!!! Pawn.SetPhysics(PHYS_Walking); } } event EndState(Name NextStateName) { GroundPitch = 0; if ( Pawn != None ) { Pawn.SetRemoteViewPitch( 0 ); if ( bDuck == 0 ) { Pawn.ShouldCrouch(false); } } } Begin: } DefaultProperties { }
Code:
class Mod2Game extends UTGame; defaultproperties { bRestartLevel=False //bUseClassicHUD=true DefaultPawnClass=class'MyMod2.Mod2Pawn' PlayerControllerClass=class'MyMod2.Mod2PlayerController' //MapPrefixes[0]="UDN" bDelayedStart = false }
TUTORIAL
Ok, so grab the MyMod2 zip from here: https://drive.google.com/file/d/0B2r...it?usp=sharing
Unzip and place MyMod2 in UDK>Development > Src
Then head over to UDK > UDKGame > Config
Double click DefaultEngine.ini find where it says +EditPackages=UTGameContent and underneath that type +EditPackages=MyMod2
Boot up UnrealFront end, build scripts, and then fire up the editor
In the editor make sure you select World properties > Game Type and select MyMod from there
Play the game and the new camera and movement should be in place
Comment