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 |
/** * A sample lever to be triggered by the Use() exec function. * Triggers have to be used in Kismet, otherwise Use() will not find it * * 2013 by FreetimeCoder * www.freetimestudio.net */ class AdvKitLeverTrigger extends Trigger placeable ClassGroup(AdvKit); //mesh to represent the lever var SkeletalMeshComponent mesh; //node to control the lever's animations var AnimNodePlayCustomAnim customAnim; //simple switch variable to store the levers state var() bool bActivated; //local offset to set the Pawn to that is using the lever var() Vector vPawnOffset; //animations for the lever var name nAnim_Activation; var name nAnim_Deactivation; /**Actor.uc: * called after initializing the AnimTree for the given SkeletalMeshComponent that has this Actor as its Owner * this is a good place to cache references to skeletal controllers, etc that the Actor modifies * * @param _skelComp the SkeletalMeshComponent that has been initialized */ simulated event PostInitAnimTree(SkeletalMeshComponent _skelComp) { super.PostInitAnimTree(_skelComp); //find the CustomAnim node within the Anim Tree if (_skelComp == mesh) { customAnim = AnimNodePlayCustomAnim(_skelComp.FindAnimNode('CustomAnim')); } } /**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 PlayedTime - Time played on this animation. (play rate independant). * @param ExcessTime - how much time overlapped beyond end of animation. (play rate independant). */ event OnAnimEnd(AnimNodeSequence SeqNode, float PlayedTime, float ExcessTime) { //Switch state when lever is finished toggle animation switch(SeqNode.AnimSeqName) { case 'Activate': case 'Deactivate': bActivated = !bActivated; break; } } /**Actor.uc: * "Called when being activated by the specified pawn. Default * implementation searches for any SeqEvent_Used and activates * them." * * This has been modified to animate the lever and check if the * pawn is of the type AdvKitPawn * * @return true to indicate this actor was activated */ function bool UsedBy(Pawn User) { local Vector vOffsetLocation; local AdvKitPawn advPawn; advPawn = AdvKitPawn(User); if(advPawn != none) { //play animation depending on state if(!bActivated) { if(advPawn.Controller.IsA('AdvKitPlayerController')) { AdvKitPlayerController(advPawn.Controller).Interact(EIS_ActivateLever); } if(customAnim!=none) { customAnim.PlayCustomAnim(nAnim_Activation,1,0,0,false); } } else { if(advPawn.Controller.IsA('AdvKitPlayerController')) { AdvKitPlayerController(advPawn.Controller).Interact(EIS_DeactivateLever); } if(customAnim!=none) { customAnim.PlayCustomAnim(nAnim_Deactivation,1,0,0,false); } } //position the pawn to sync the animations vOffsetLocation = vPawnOffset >> Rotation; User.ZeroMovementVariables(); advPawn.SetLocation(Location+vOffsetLocation); advPawn.SetRotation(Rotation); //notify Kismet etc. return super.UsedBy(User); } //done nothing return false; } defaultproperties { //do not show the sprite while in game Begin Object Name=Sprite HiddenGame=true End Object //set up the mesh to show in game begin object Class=SkeletalMeshComponent Name=MeshComp0 AnimSets(0)=AnimSet'AdvKit_Assets.Lever.S_Lever_Anims' AnimTreeTemplate=AnimTree'AdvKit_Assets.Lever.AT_Lever' SkeletalMesh=SkeletalMesh'AdvKit_Assets.Lever.S_Lever' //I messed up the mesh transform, so I have to correct it here Scale = 13 Translation=(Z=-40) CastShadow=true bCastDynamicShadow=true End Object mesh=MeshComp0; Components.Add(MeshComp0) //show in game bHidden = false vPawnOffset = (X=-28.0,Y=0.0,Z=15.0) //assign animation names nAnim_Activation = Activate nAnim_Deactivation = Deactivate } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |