Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 00910 00911 00912 00913 00914 00915 00916 00917 00918 00919 00920 00921 00922 00923 00924 00925 00926 00927 00928 00929 00930 00931 00932 00933 00934 00935 00936 00937 00938 00939 00940 00941 00942 00943 00944 00945 00946 00947 00948 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 00962 00963 00964 00965 00966 00967 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00980 00981 00982 00983 00984 00985 00986 00987 00988 |
/** * Adventure Kit Pawn * * The pawn mainly contains alot of variables to configure it behaviour * but also has some utility and overriden functions * * 2013 by FreetimeCoder * www.freetimestudio.net */ class AdvKitPawn extends Pawn; /*hold a AdvKitPlayerController reference to prevent alot of unecessary casting (set in PossessedBy)*/ var AdvKitPlayerController advController; /*trace length for CheckFloor function in the Controller*/ var float fFloorTraceLength; /*lerp speed used to smoothly rotate pawn*/ var float fRotationLerpSpeed; /** * Replacement for AnimNodeBlendDirectional as described here: * http://www.sanzpont.com/chosker/elium/?p=326 */ var float fAnimTreeSideDirectionBlend; /** * Replacement for AnimNodeBlendDirectional as described here: * http://www.sanzpont.com/chosker/elium/?p=326 */ var float fAnimTreeFrontDirectionBlend; /**the current adventureState*/ enum EAdventureState { EAS_Default, EAS_TightSpaceWalking, EAS_Sliding, EAS_Swimming, EAS_Balancing, EAS_WallClimbing, EAS_LedgeClimbing, EAS_CeilingClimbing, EAS_PoleClimbing, EAS_WallJumping, EAS_Interacting }; /**the current adventureState*/ var EAdventureState adventureState; /**----------Root Motion Control----------**/ /**Pawn is currently executing RootMotion*/ var PrivateWrite bool bInRootMotion; /**Pawn is currently executing RootMotion Rotation*/ var PrivateWrite bool bInRootRotation; /**-------------Sliding------------------**/ /**how much control the pawn has on the current slide*/ var float fSlideControlStrength; /**how long the Z trace is from the Pawn's location to find a slide*/ var float fSlideTraceLength; /**normal of the current slope*/ var Vector vSlopeNormal; /**tangent of the current slope*/ var Vector vSlopeTangent; /**-------------Vaulting-----------------**/ /**how far ahead to look for obstructions*/ var float fVaultLookAheadDist; /**the height to trace for obstructions*/ var float fVaultHeight; /**the length of the Trace determine vaulting*/ var float fVaultTraceDepth; /**is the pawn currently vaulting? for the AnimTree*/ var bool bVaulting; /**--------Swimming/Diving--------------**/ /**Z location of the current water volume's surface*/ var float fWaterSurfaceZ; /**the enumerations for the water state*/ enum EWaterState { EWS_Swimming, EWS_StartDiving, EWS_Diving }; /**the current water state*/ var EWaterState swimmingState; /**-----------Wall Jumping------------**/ /**how long the pawn stays on the wall during a wall jump before falling down*/ var float fWallJumpFallDownTime; /**how fast to jump from a wall*/ var Vector vWallJumpSpeed; /**enumeration for walljump states*/ enum EWallJumpState { EWJS_Default, EWJS_JumpBack }; /**the current walljump state*/ var EWallJumpState wallJumpingState; /**-----------Wall climbing-------------**/ /**How fast the pawn can climb on a wall*/ var vector vWallClimbSpeed; /**the current wall the Pawn is climbing on*/ var Actor currentWall; /**the current wall's normal*/ var Vector vCurrentWallNormal; /**local trace start location for checking if it is possible to go around an edge*/ var Vector2D v2WallEdgeTraceNear; /**local trace start location for checking if it is possible to go around an edge*/ var Vector2D v2WallEdgeTraceFar; /**trace variables to find out if the pawn can climb up on top of a wall*/ var float fWallTraceLength; /**how high the trace should be to check for possible climb up locations*/ var float fWallClimbClimbUpTraceHeight; /**how long the trace should be to check for possible climb up locations*/ var float fWallClimbClimbUpTraceLength; /**how steep the top can be to still climb up*/ var float fWallClimbTopMinNormal; /**how long the trace should be to check for a ceiling*/ var float fCeilingTraceLength; /**enumeration for the climbing state*/ enum EWallClimbState { EWCS_Default, EWCS_ScaleUp, EWCS_AroundCornerLeft, EWCS_AroundCornerRight, EWCS_ToCeiling, EWCS_JumpBack }; /**the wall climbing state*/ var EWallClimbState wallClimbingState; /**---------Ceiling Climbing-----------**/ /**how fast the pawn can climb on a wall*/ var float fCeilingClimbSpeed; /**enumeration for the ceiling climbing state*/ enum ECeilingClimbState { ECCS_Default, ECCS_ClimbToWall }; /**the current ceiling climb state*/ var ECeilingClimbState ceilingClimbingState; /**-----------Pole Climbing------------**/ /**pole that pawn is climbing on*/ var AdvKitPole currentPole; /**how fast to climb around the pole*/ var float fClimbDegreePerSec; /**how fast to climb up the pole*/ var float fClimbPoleSpeed; /**the offset distance from the pole to place the pawn*/ var float fClimbPoleDistance; /**the velocity of the jump from a pole while climbing*/ var Vector vClimbPoleJumpSpeed; /**the velocity of the jump from a pole while standing on it*/ var Vector vStandPoleJumpSpeed; /**How high the pawn should stand on a pole*/ var float fStandPoleHeight; /**enumeration for the current pole climbing state*/ enum EPoleClimbState { EWPS_ClimbPole, EWPS_PreBackJump, EWPS_ClimpUp, EWPS_StandOnPole, EWPS_ClimbDown, EWPS_JumpBack }; /**the current pole climbing state*/ var EPoleClimbState poleClimbingState; /**----------Spline Movement-----------**/ /**the current spline the pawn is using*/ var PrivateWrite AdvKitSplineActor currentSpline; /**the distance on the spline (which is used to calculate position, tangent and normal) * 0 <= distance <= spline length * */ var PrivateWrite float fCurrentSplineDistance; /**current location on the spline in global space*/ var PrivateWrite Vector vCurrentSplineLocation; /**current tangent of the spline in global space*/ var PrivateWrite Vector vCurrentSplineTangent; /**current normal of the spline in global space*/ var PrivateWrite Vector vCurrentSplineNormal; /**current location on the spline in local space*/ var PrivateWrite Vector vCurrentSplineRelativeLocation; /**current tangent of the spline in local space*/ var PrivateWrite Vector vCurrentSplineRelativeTangent; /**current normal of the spline in local space*/ var PrivateWrite Vector vCurrentSplineRelativeNormal; /**-------Tight Space Movement---------**/ /**offset to position the pawn from the spline*/ var Vector vTightSpaceOffset; /**offset to position the pawn from the spline when starting transition animation*/ var Vector vTightSpaceStartOffset; /**how fast the pawn moves on the spline*/ var float fTightSpaceWalkSpeed; /**how far to check for tight space spline actors*/ var float fMaxTightspaceCheckDistance; /**the max distance for locations on the spline curve to start using the spline*/ var float fMaxTightspaceAcceptDistance; /**enumeration for the tightspace state*/ enum ETightSpaceState { ETSS_Default_Wall_Left, ETSS_Enter_Wall_Left, ETSS_Leave_Wall_Left, ETSS_Default_Wall_Right, ETSS_Enter_Wall_Right, ETSS_Leave_Wall_Right }; /**the current tightspace state*/ var ETightSpaceState tightSpaceState; /**-----------Ledge Climbing-----------**/ /**trace distances to use for checking walls or if the pawn can climb up*/ var float fWallCheckTraceLength; /**internal variable, true in case there is a wall under the ledge*/ var bool bLedgeClimbOnWall; /**how far in front of the pawn to start tracing*/ var float fLedgeGrabTraceXOffset; /**how high above the pawn to start tracing*/ var float fLedgeGrabTraceHeight; /**the length of the trace*/ var float fLedgeGrabTraceLength; /**the maximum distance to check for ledge spline actors*/ var float fMaxLedgeCheckDistance; /**the maximum distance to a location on a spline to accept the spline*/ var float fMaxLedgeAcceptDistance; /**how high above the pawn to start the climb up trace*/ var float fLedgeClimb_ClimbUpTraceHeight; /**the length of the climb up trace*/ var float fLedgeClimb_ClimbUpTraceLength; /**how fast the pawn can move on the ledge if it has a wall*/ var float fLedgeClimb_SpeedWall; /**how fast the pawn can move on the ledge if it has no wall*/ var float fLedgeClimb_SpeedNoWall; /**the maximum dot product a ledge can have to (0,0,1) to count as a ledge*/ var float fLedgeClimb_MinNormal; /**offset to place the pawn from the spline curve*/ var Vector vLedgeClimbOffset; /**angle of a left edge in order to climb around*/ var float fLedeAngleCornerLeft; /**angle of a right edge in order to climb around*/ var float fLedeAngleCornerRight; //jumping speed variables /**the speed (in local space) to jump backwards when on a ledge*/ var Vector vLedgeClimbJumpSpeedBack; /**the speed (in local space) to jump upwards when on a ledge*/ var Vector vLedgeClimbJumpSpeedUp; /**the speed (in local space) to jump left when on a ledge*/ var Vector vLedgeClimbJumpSpeedLeft; /**the speed (in local space) to jump right when on a ledge*/ var Vector vLedgeClimbJumpSpeedRight; /**enumeration for the ledge climb state*/ enum ELedgeClimbState { ELCS_Default, ELCS_ClimbUp, ELCS_PreJumpUp, ELCS_JumpUp, ELCS_PreJumpBack, ELCS_JumpBack, ELCS_PreJumpLeft, ELCS_JumpLeft, ELCS_PreJumpRight, ELCS_JumpRight, ELCS_JumpDown, ELCS_ClimbAroundEdgeLeft, ELCS_ClimbAroundEdgeRight, ELCS_FallingLedgeGrab }; /**the current ledge climb state*/ var ELedgeClimbState ledgeClimbingState; /**--------------Balancing-------------**/ /**how balanced the pawn is (from -1 to 1, 0 is complete balance)*/ var float fBalance; /**lerp target for balance to keep tansitions jitter free*/ var float fTargetBalance; /**how fast balance changes*/ var float fBalanceDifficulty; /**how fast the pawn can walk while balancing*/ var float fBalancingWalkSpeed; /**speed to jump when the player looses balance*/ var Vector vBalanceFallOffSpeed; /**speed to use when the player jumps*/ var Vector vBalanceJumpOffSpeed; /**the minimum normal dot product to make the pawn jump (like MinHitWall)*/ var float fBalanceMinJumpOff; /**the maximum distance to check for balance spline actors*/ var float fMaxBalanceCheckDistance; /**the maximum distance for the closest position on a spline to accept the spline*/ var float fMaxBalanceAcceptDistance; /**--------------Interacting-------------**/ /**enumeration for the interaction state*/ enum EInteractionState { EIS_None, EIS_ActivateLever, EIS_DeactivateLever /*To be expanded*/ }; /**the current interaction state*/ var EInteractionState interactionState; /**Make the pawn jump * * @param _bUpdating (not necessary because this kit is not multiplayer) * @return true if jump was done */ function bool DoJump( bool _bUpdating ) { local Vector vXYAccel; local Vector vLocalAccel; local float fDotProduct; switch(adventureState) { case EAS_Default: //rotate pawn to acceleration and then use the regular jump function vXYAccel = Acceleration; vXYAccel.Z = 0; if(VSize(vXYAccel)!=0) { SetRotation(Rotator(vXYAccel)); } return super.DoJump(_bUpdating); case EAS_TightSpaceWalking: break; case EAS_Sliding: //Keep velocity but add upward jump speed Velocity.Z = JumpZ; //Prevent the pawn from doing a super fast leap upon physics change Acceleration = vect(0,0,0); SetPhysics(PHYS_Falling); return true; case EAS_Swimming: break; case EAS_Balancing: vXYAccel = Acceleration; vXYAccel.Z = 0; if(VSize(vXYAccel)>0) { vLocalAccel = Normal(Global2RelativeDirection(vXYAccel)); fDotProduct = vLocalAccel dot vCurrentSplineRelativeNormal; if(Abs(fDotProduct)>fBalanceMinJumpOff) { SetPhysics(PHYS_Falling); SetRotation(Rotator(Normal(vXYAccel))); Velocity = (Normal(vXYAccel)*vBalanceJumpOffSpeed.X+vect(0,0,1)*vBalanceJumpOffSpeed.Z); return true; } } break; case EAS_WallClimbing: //jump away from the wall SetPhysics(PHYS_Falling); Velocity = (vect(-1,0,1)*vWallJumpSpeed)>>Rotation; wallClimbingState = EWCS_JumpBack; ActivateRootMotion(RMM_Ignore, RMRM_RotateActor); return true; case EAS_LedgeClimbing: //ledge climb jumps are driven by root motion switch(ledgeClimbingState) { case ELCS_PreJumpUp: SetPhysics(PHYS_Falling); ledgeClimbingState = ELCS_JumpUp; Velocity = vLedgeClimbJumpSpeedUp>>Rotation; ActivateRootMotion(RMM_Accel,RMRM_RotateActor); return true; case ELCS_PreJumpBack: SetPhysics(PHYS_Falling); SetCollision(true, true); bCollideWorld = true; ledgeClimbingState = ELCS_JumpBack; Velocity = vLedgeClimbJumpSpeedBack>>Rotation; ActivateRootMotion(RMM_Ignore,RMRM_RotateActor); return true; case ELCS_PreJumpLeft: SetPhysics(PHYS_Falling); ledgeClimbingState = ELCS_JumpLeft; Velocity = vLedgeClimbJumpSpeedLeft>>Rotation; ActivateRootMotion(RMM_Ignore,RMRM_RotateActor); return true; case ELCS_PreJumpRight: SetPhysics(PHYS_Falling); ledgeClimbingState = ELCS_JumpRight; Velocity = vLedgeClimbJumpSpeedRight>>Rotation; ActivateRootMotion(RMM_Ignore,RMRM_RotateActor); return true; } break; case EAS_CeilingClimbing: break; case EAS_PoleClimbing: switch(poleClimbingState) { case EWPS_PreBackJump: //jump away from the pole poleClimbingState = EWPS_JumpBack; SetPhysics(PHYS_Falling); Velocity = vClimbPoleJumpSpeed>>Rotation; ActivateRootMotion(RMM_Ignore,RMRM_RotateActor); return true; case EWPS_StandOnPole: //jump in the direction the player is looking if(VSize(Acceleration)!=0) { SetRotation(Rotator(vect(1,1,0)*Acceleration)); } Velocity = vStandPoleJumpSpeed>>Rotation; SetPhysics(PHYS_Falling); return true; } break; case EAS_WallJumping: if(wallJumpingState == EWJS_Default) { //jump away from wall wallJumpingState = EWJS_JumpBack; SetPhysics(PHYS_Falling); Velocity = (vect(-1,0,1)*vWallJumpSpeed)>>Rotation; ActivateRootMotion(RMM_Ignore, RMRM_RotateActor); return true; } break; } //no jump possible return false; } /**Pawn.uc: * Event called after actor's base changes. */ event BaseChange() { super.BaseChange(); //SetBase for Controller to prevent the camera "drifting away" when base is moving if(AdvKitPlayerController(Controller)!=none) { if(Physics != PHYS_Walking) { Controller.SetBase(Base); } else { //UDK handles this natively somehow, do not interfere Controller.SetBase(none); } } } /**Pawn.uc: * Pawn is possessed by Controller */ function PossessedBy(Controller C, bool bVehicleTransition) { super.PossessedBy(C,bVehicleTransition); advController = AdvKitPlayerController(C); } /**Set the current pole for climbing * * @param _newPole the pole to climb on */ final function SetCurrentPole(AdvKitPole _newPole) { if(_newPole!=none) { SetPhysics(PHYS_Interpolating); } currentPole = _newPole; SetHardAttach(_newPole!=none); SetBase(currentPole); } /**Set the current wall for climbing * * @param _wall the actor to climb on * @param _vWallNormal normal of the walls surface in global space */ final function SetCurrentWall(Actor _wall, optional Vector _vWallNormal) { if(_wall!=none) { SetPhysics(PHYS_Interpolating); } currentWall = _wall; SetHardAttach(_wall!=none); SetBase(_wall); vCurrentWallNormal = Global2RelativeDirection(_vWallNormal); SetRelativeLocation(Global2RelativePosition(Location)); if(VSize(_vWallNormal)!=0) { SetRelativeRotation(Rotator(-vCurrentWallNormal)); } } /**Called when the currentSpline changed * * @param _newSplineActor the new (current) actor * @param _oldsplineActor the old actor */ event OnSplineChanged(AdvKitSplineActor _newSplineActor, AdvKitSplineActor _oldSplineActor) { local AdvKitSplineActorBalance tmpBalanceSpline; //in case it is a balance spline, update the difficulty tmpBalanceSpline = AdvKitSplineActorBalance(_newSplineActor); if(tmpBalanceSpline!=none) { fBalanceDifficulty = tmpBalanceSpline.fBalanceDifficulty; } } /**Add a delta to the current spline distance * * @param _fNewDelta the delta to add * @param _bForceUpdate whether to update spline values even if delta is zero */ final function SetDeltaSplineDistance(float _fNewDelta, optional bool _bForceUpdate) { SetSplineDistance(fCurrentSplineDistance + _fNewDelta,_bForceUpdate); } /**Set the current spline distance * * @param _fNewDistance the new distance * @param _bForceUpdate whether to update spline values even if distance is zero */ final function SetSplineDistance(float _fNewDistance, optional bool _bForceUpdate) { if(fCurrentSplineDistance!=_fNewDistance || _bForceUpdate) { if(currentSpline!=none) { //set new spline actor in case the new distance goes over the current spline if(_fNewDistance>currentSpline.GetSplineLength()) { if(currentSpline.HasNext() && currentSpline.GetNext().HasNext()) { SetCurrentSpline(currentSpline.GetNext(), _fNewDistance - currentSpline.GetSplineLength()); //SetCurrentSpline calls SetSplineDistance, so no need to go further down return; } } if(_fNewDistance<0) { if(currentSpline.HasPrevious()) { SetCurrentSpline(currentSpline.GetPrevious(), currentSpline.GetPrevious().GetSplineLength()+_fNewDistance); //SetCurrentSpline calls SetSplineDistance, so no need to go further down return; } } } //update spline variables fCurrentSplineDistance=_fNewDistance; if(currentSpline!=none) { vCurrentSplineLocation = currentSpline.GetLocationAtDistanceAlongSpline(fCurrentSplineDistance); vCurrentSplineTangent = currentSpline.GetTangentAtDistanceAlongSpline(fCurrentSplineDistance); vCurrentSplineNormal = currentSpline.GetNormalAtDistanceAlongSpline(fCurrentSplineDistance); vCurrentSplineRelativeLocation = Global2RelativePosition(vCurrentSplineLocation); vCurrentSplineRelativeTangent = Global2RelativeDirection(vCurrentSplineTangent); vCurrentSplineRelativeNormal = Global2RelativeDirection(vCurrentSplineNormal); } } } /**Set a new spline actor * * @param _newSpline the new actor to set * @param _fNewsplineDistance the new distance on the spline */ final function SetCurrentSpline(AdvKitSplineActor _newSpline, optional float _fNewSplineDistance) { local AdvKitSplineActor lastSpline; local bool bIsNewSpline; lastSpline = currentSpline; bIsNewSpline = currentSpline!=_newSpline; SetHardAttach(_newSpline!=none); currentSpline = _newSpline; SetBase(_newSpline); if(_newSpline!=none) { //only call notifiers if it is a new spline actor if(bIsNewSpline) { //notify the controller and call the pawns change event if(advController==none || !advController.NotifySplineChanged(currentSpline,lastSpline)) { OnSplineChanged(currentSpline,lastSpline); } } //update the spline distance SetSplineDistance(_fNewSplineDistance, true); return; } } /**The Pawn has entered a new PhsyicsVolume * * @param _NewVolume the entered volume */ event PhysicsVolumeChange( PhysicsVolume _NewVolume ) { super.PhysicsVolumeChange(_NewVolume); //in case the volume is a WaterVolume, update the surface value if(AdvKitWaterVolume(_NewVolume) != none) { fWaterSurfaceZ = AdvKitWaterVolume(_NewVolume).fSurfaceHeight; } } /**Convert a global location into a relative location of Base * (use with SetRelativeLocation) * * @param _vGlobalPosition position in global space * @return position in local space */ final function Vector Global2RelativePosition(Vector _vGlobalPosition) { /* //Long explained version local Vector vRelativePosition; //only do stuff if Pawn has a base if(Base!=none) { vRelativePosition = _vGlobalPosition - Base.Location; vRelativePosition = vRelativePosition << Base.Rotation; return vRelativePosition; } //Short optimized version */ return (Base!=none) ? ((_vGlobalPosition - Base.Location) << Base.Rotation) : _vGlobalPosition; } /**Convert a global direction into a relative direction of Base * * @param _vGlobalDirection direction in global space * @return direction in local space */ final function Vector Global2RelativeDirection(Vector _vGlobalDirection) { /* //Long explained version if(Base!=none) { return _vGlobalDirection << Base.Rotation; } return _vGlobalDirection; //Short optimized version */ return (Base!=none) ? (_vGlobalDirection << Base.Rotation) : _vGlobalDirection; } /**Convert a relative direction in Base space into a global direction * * @param _vRelativeDirection direction in local space * @return direction in global space */ final function Vector Relative2GlobalDirection(Vector _vRelativeDirection) { /* //Long explained version if(Base!=none) { return _vRelativeDirection >> Base.Rotation; } return _vRelativeDirection; //Short optimized version */ return (Base!=none) ? (_vRelativeDirection >> Base.Rotation) : _vRelativeDirection; } /**Actor.uc: * Event called when an AnimNodeSequence (in the animation tree of one of this Actor's SkeletalMeshComponents) reaches the end and stops. * Will not get called if bLooping is 'true' on the AnimNodeSequence. * bCauseActorAnimEnd must be set 'true' on the AnimNodeSequence for this event to get generated. * * @param _seqNode - Node that finished playing. You can get to the SkeletalMeshComponent by looking at SeqNode->SkelComponent * @param _fPlayedTime - Time played on this animation. (play rate independant). * @param _fExcessTime - how much time overlapped beyond end of animation. (play rate independant). */ event OnAnimEnd(AnimNodeSequence _seqNode, float _fPlayedTime, float _fExcessTime) { DeactivateRootMotion(); //notify the advController if present if(advController!=none) { advController.NotifyOnAnimEnd(_seqNode,_fPlayedTime, _fExcessTime); } } /**Pawn.uc: * returns default camera mode when viewing this pawn. * Mainly called when controller possesses this pawn. * * @param _requestedBy requesting the default camera view * @return default camera view player should use when controlling this pawn. */ simulated function name GetDefaultCameraMode(PlayerController _requestedBy) { return 'ThirdPerson'; } /**Activate root motion for animations * * @param _RMMode translation mode * @param _RMRMode rotation mode */ final function ActivateRootMotion(optional ERootMotionMode _RMMode, optional ERootMotionRotationMode _RMRMode) { //Reset everything first DeactivateRootMotion(); //set flags bInRootMotion = (_RMMode!=RMM_Ignore); bInRootRotation = (_RMRMode!=RMRM_Ignore); //set modes Mesh.RootMotionMode = _RMMode; Mesh.RootMotionRotationMode = _RMRMode; } /**Deactivate root motion for animations */ final function DeactivateRootMotion() { //disable flags bInRootMotion=false; bInRootRotation=false; //set modes Mesh.RootMotionMode = RMM_Ignore; Mesh.RootMotionRotationMode = RMRM_Ignore; } /**Get the default collision height of the cylinder * Since the cylinder is modified in some controller state it helps * to have a function to get the default value * * @return the default height */ final function float GetCollisionHeightDefault() { if(CylinderComponent != none) { return CylinderComponent.default.CollisionHeight; } return 0; } /**Get the default collision radius of the cylinder * Since the cylinder is modified in some controller state it helps * to have a function to get the default value * * @return the default radius */ final function float GetCollisionRadiusDefault() { if(CylinderComponent != none) { return CylinderComponent.default.CollisionRadius; } return 0; } DefaultProperties { //Components.Remove(Sprite) Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment End Object Components.Add(MyLightEnvironment) Begin Object Class=SkeletalMeshComponent Name=InitialSkeletalMesh CastShadow=true bCastDynamicShadow=true bOwnerNoSee=false LightEnvironment=MyLightEnvironment; BlockRigidBody=false; CollideActors=false; BlockZeroExtent=false; AnimSets(0)=AnimSet'AdvKit_Pawn.AS_AdvKit_Pawn' AnimTreeTemplate=AnimTree'AdvKit_Pawn.AT_AdvKit_Pawn' SkeletalMesh=SkeletalMesh'AdvKit_Pawn.SK_AdvKit_Pawn' PhysicsAsset=PhysicsAsset'AdvKit_Pawn.PA_AdvKit_Pawn' Scale = 13 End Object Mesh=InitialSkeletalMesh; Components.Add(InitialSkeletalMesh); CollisionType=COLLIDE_BlockAll Begin Object Name=CollisionCylinder CollisionRadius=15 CollisionHeight=49 End Object CylinderComponent=CollisionCylinder CollisionComponent=CollisionCylinder fRotationLerpSpeed = 10 fFloorTraceLength = 55 //Sliding fSlideTraceLength = 128 bAlwaysEncroachCheck = true WalkingPct=0.25 GroundSpeed = 600 //To keep the pawn from sinking while diving Buoyancy = 1 fVaultLookAheadDist = 17 fVaultHeight = 15 fVaultTraceDepth = 16 fLedgeClimb_SpeedWall=50 fLedgeClimb_SpeedNoWall=20 fLedgeClimb_MinNormal = 0.3 fLedgeClimb_ClimbUpTraceHeight = 50 fLedgeClimb_ClimbUpTraceLength = 64 vLedgeClimbOffset=(X=10,Z=-38) fLedeAngleCornerLeft=130 fLedeAngleCornerRight=-85 fWallCheckTraceLength = 32 fLedgeGrabTraceXOffset=25 fLedgeGrabTraceHeight=50 fLedgeGrabTraceLength=16 fMaxLedgeCheckDistance=512 fMaxLedgeAcceptDistance=32 vLedgeClimbJumpSpeedBack=(X=-300, Z=400) vLedgeClimbJumpSpeedUp=(Z=450) vLedgeClimbJumpSpeedLeft=(Y=-180, Z=400) vLedgeClimbJumpSpeedRight=(Y=180, Z=400) fBalancingWalkSpeed=60 vBalanceFallOffSpeed = (Y=100,Z=200); vBalanceJumpOffSpeed = (X=300,Z=250); fBalanceMinJumpOff = 0.7 fMaxBalanceCheckDistance=512 fMaxBalanceAcceptDistance=32 fClimbDegreePerSec=90 fClimbPoleSpeed=60 fClimbPoleDistance=0 vClimbPoleJumpSpeed = (X=-300,Z=300) vStandPoleJumpSpeed = (X=400,Z=200) fStandPoleHeight = 52 vWallClimbSpeed=(Y=50,Z=50) v2WallEdgeTraceNear=(X=25, Y=25) v2WallEdgeTraceFar=(X=34.5, Y=25) fWallTraceLength=25 fWallClimbClimbUpTraceHeight=52 fWallClimbClimbUpTraceLength=64 fCeilingTraceLength = 55 fCeilingClimbSpeed=50 JumpZ= 400 fWallJumpFallDownTime=0.5 vWallJumpSpeed=(X=300, Z=400) vTightSpaceOffset=(Z=50); vTightSpaceStartOffset=(X=15,Y=10,Z=52); fTightSpaceWalkSpeed=50; fMaxTightspaceCheckDistance=256 fMaxTightspaceAcceptDistance=32 AirControl = 0 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |