Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- APlayerPawn* PPawn = Cast<APlayerPawn>(this);
- if( PPawn && PPawn->bAutoJump )
- {
- static float MinAutoJumpCos = 0.25f;
- static float AutoJumpThreshold = 10.f;
- // Check whether center has crossed a ledge.
- FVector FootDel = FVector(0,0,-CollisionHeight);
- FVector SubFootDel = FVector(0,0,-CollisionHeight-4.f);
- if( !bZeroMove && GetLevel()->SingleLineCheck( Hit, this, Location + FootDel + Down, Location, TRACE_AllBlocking | TRACE_StopAtFirstHit) )
- {
- // Find exact location of ledge.
- FVector Back = Location - AccelDir * (CollisionRadius*1.5f);
- if( !GetLevel()->SingleLineCheck( Hit, this, Back + SubFootDel, Location + SubFootDel, TRACE_AllBlocking | TRACE_StopAtFirstHit) )
- {
- FLOAT Cos = Hit.Normal | AccelDir;
- if( Cos > MinAutoJumpCos )
- {
- // Crossed ledge this tick. See whether we'd really fall on ledge edge.
- // Move player out to ledge location.
- FLOAT t = Hit.Time;
- FVector EdgeLoc = Back * t + Location * (1.f-t);
- // Find where we fall, and where we jump.
- FVector Start = EdgeLoc + AccelDir * (CollisionRadius*1.5f/Cos);
- Predict( Hit, this, Start, Velocity, Extent, 2.f );
- FVector Fall = Hit.Location;
- Predict( Hit, this, EdgeLoc, Velocity + FVector(0,0,JumpZ), Extent, 2.f );
- FVector Jump = Hit.Location;
- if( Jump.Z - Fall.Z > AutoJumpThreshold )
- {
- // Jumping is better.
- // Move back to edge location, then jump.
- GetLevel()->MoveActor(this, EdgeLoc - Location, Rotation, Hit);
- PPawn->eventDoJump(1.f);
- remainingTime += timeTick * t;
- physFalling(remainingTime, Iterations);
- return;
- }
- }
- }
- }
- }
RAW Paste Data