Using a simple Custom-Kismet-Node I want to access the unreal-script that gives a player Flying ability around a level. The core code is invoked from the CheatManager.uc which invokes a GotoState in PlayerController.uc... I've copied the code into a self-contained Custom Node file, and it compiles ok. But it doesn't match the behavior of the 'Fly' console command. The only active code appears to be this: SetPhysics('PlayerFlying'). The problem is, it doesn't offer the CTRL / C key altitude control that 'Fly' has, so its impossible for the player to navigate. There's been a lot of requests for this feature in past posts stretching back a long time, so I know someone has solved it... Please help...
Custom Kismet Node
PlayerController.uc -> State PlayerFlying
UTPlayerController.uc -> State PlayerFlying
CheatManager.uc -> Fly
Custom Kismet Node
Code:
class F_UTSeqAct_Flying extends SequenceAction; event Activated() { local SeqVar_Object ObjVar; local Pawn Target; local vector X,Y,Z; local PlayerController PlayerController; local WorldInfo WorldInfo; local float DeltaTime; //ignores SeePlayer, HearNoise, Bump; // get the pawn(s) that should enter the vehicle foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target") { Target = GetPawn(Actor(ObjVar.GetObjectValue())); WorldInfo = class'WorldInfo'.static.GetWorldInfo(); DeltaTime = WorldInfo.TimeSeconds - 1.0; //- LastCameraTimeStamp; PlayerController = WorldInfo.GetALocalPlayerController(); PlayerController.bCheatFlying = true; GetAxes(Target.Rotation,X,Y,Z); Target.Acceleration = PlayerController.PlayerInput.aForward*X + PlayerController.PlayerInput.aStrafe*Y + PlayerController.PlayerInput.aUp*vect(0,0,1);; Target.Acceleration = Target.AccelRate * Normal(Target.Acceleration); if ( (Target.Acceleration == vect(0,0,0)) ) Target.Velocity = vect(0,0,0); // Update rotation. PlayerController.UpdateRotation( DeltaTime ); if ( PlayerController.Role < ROLE_Authority ) // then save this move and replicate it PlayerController.ReplicateMove(DeltaTime, Target.Acceleration, DCLICK_None, rot(0,0,0)); else PlayerController.ProcessMove(DeltaTime, Target.Acceleration, DCLICK_None, rot(0,0,0)); PlayerController.CheckJumpOrDuck(); Target.SetPhysics(PHYS_Flying); } } defaultproperties { bCallHandler=false ObjCategory="F" ObjName="Flying" VariableLinks(0)=(MinVars=1,MaxVars=1) }
Code:
Begin: } state PlayerFlying { ignores SeePlayer, HearNoise, Bump; function PlayerMove(float DeltaTime) { local vector X,Y,Z; GetAxes(Rotation,X,Y,Z); Pawn.Acceleration = PlayerInput.aForward*X + PlayerInput.aStrafe*Y + PlayerInput.aUp*vect(0,0,1);; Pawn.Acceleration = Pawn.AccelRate * Normal(Pawn.Acceleration); if ( bCheatFlying && (Pawn.Acceleration == vect(0,0,0)) ) Pawn.Velocity = vect(0,0,0); // 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); } }
UTPlayerController.uc -> State PlayerFlying
Code:
state PlayerFlying { ignores SeePlayer, HearNoise, Bump; function PlayerMove(float DeltaTime) { Super.PlayerMove(DeltaTime); CheckJumpOrDuck(); } }
Code:
exec function Fly() { if ( (Pawn != None) && Pawn.CheatFly() ) { ClientMessage("You feel much lighter"); bCheatFlying = true; Outer.GotoState('PlayerFlying'); } }
Comment