This may be helpful to you because it includes the possibility for animation, hence it may help you out with your doorhandle.
defaultproperties are sparce but should be easy enough to work out.
Code:
class AFFSkeletalDoor extends SkeletalMeshActor hidecategories(Navigation) placeable; enum SkeletalDoorState { DoorState_Open, DoorState_Opening, DoorState_Closed, DoorState_Closing, DoorState_Destroyed, DoorState_None, }; var() float Health; var bool bReverseOpenToClose; var() SoundCue ClosedSound; var() SoundCue OpenedSound; var() SoundCue CloseSound; var() SoundCue OpenSound; var() /* 00000008 */ AudioComponent SoundComponent; var() float DoorClosingTime; var() float DoorOpeningTime; var SkeletalDoorState NextDoorState; var SkeletalDoorState LastDoorState; var() SkeletalDoorState DoorState; var() EPhysics DestroyPhysics; var() Name DestroyAnimation; var() Name CloseAnimation; var() Name OpenAnimation; simulated function SetDoorState(SkeletalDoorState NewDoorState) { LastDoorState = DoorState; DoorState = NewDoorState; bForceNetUpdate = true; } simulated event TakeDamage(int DamageAmount, Controller EventInstigator, Vector HitLocation, Vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) { TakeDamage(DamageAmount, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser); if (Health > 0) { Health -= DamageAmount; if (Health <= 0) { DestroyDoor(); } } } simulated function PostBeginPlay() { PostBeginPlay(); if (DoorState == 0) { OpenDoor(true); } else { if (DoorState == 1) { OpenDoor(true); } else { if (DoorState == 2) { CloseDoor(true); } else { if (DoorState == 3) { CloseDoor(true); } else { if (DoorState == 4) { DestroyDoor(true); } } } } } } simulated function ShowDoorState() { if (DoorState == 1 || DoorState == 0 && LastDoorState != 0 && LastDoorState != 1) { OpenDoor(true); } else { if (DoorState == 3 || DoorState == 2 && LastDoorState != 2 && LastDoorState != 3) { CloseDoor(true); } else { if (DoorState == 4) { DestroyDoor(true); } } } } simulated function ReplicatedEvent(Name VarName) { if (VarName == 'DoorState') { ShowDoorState(); LastDoorState = DoorState; } else { ReplicatedEvent(VarName); } } simulated function StartDoorState(SkeletalDoorState NewDoorState, Name DoorAnimation, optional float StateDuration = 0) { SetDoorState(NewDoorState); SkeletalMeshComponent.PlayAnim(DoorAnimation, StateDuration, false); if (StateDuration > 0) { SetTimer(StateDuration, false, 'FinishDoorState'); } else { FinishDoorState(); } } simulated function ToggleDoor() { if (DoorState == 0) { CloseDoor(); } else { if (DoorState == 2) { OpenDoor(); } } } simulated function DestroyDoor(optional bool bForce = false) { if (DoorState != 4 || bForce) { SetDoorState(4); if (DestroyAnimation != 'None') { SkeletalMeshComponent.PlayAnim(DestroyAnimation, 0, false); } if (DestroyPhysics == 10 || DestroyPhysics == 2) { SkeletalMeshComponent.SetHasPhysicsAssetInstance(true); SkeletalMeshComponent.ForceSkelUpdate(); SetPhysics(DestroyPhysics); SkeletalMeshComponent.PhysicsAssetInstance.SetAllBodiesFixed(false); SkeletalMeshComponent.bUpdateKinematicBonesFromAnimation = false; SkeletalMeshComponent.WakeRigidBody(); } else { SetPhysics(DestroyPhysics); } } } simulated function CloseDoor(optional bool bForce = false) { if (DoorState == 0 || bForce) { StartDoorState(3, CloseAnimation, DoorClosingTime); PlayDoorSound(CloseSound); } else { NextDoorState = 2; } } simulated function PlayDoorSound(SoundCue S) { if (S != None && SoundComponent.SoundCue != S) { SoundComponent.SoundCue = S; SoundComponent.Play(); } } simulated function OpenDoor(optional bool bForce = false) { if (DoorState == 2 || bForce) { StartDoorState(1, OpenAnimation, DoorOpeningTime); PlayDoorSound(OpenSound); } else { NextDoorState = 0; } } simulated function FinishDoorState() { if (DoorState == 3) { SetDoorState(2); PlayDoorSound(ClosedSound); } else { if (DoorState == 1) { SetDoorState(0); PlayDoorSound(OpenedSound); } } if (DoorState != 4 && NextDoorState != 5 && NextDoorState != DoorState) { if (NextDoorState == 0) { OpenDoor(); } else { if (NextDoorState == 2) { CloseDoor(); } } } NextDoorState = 5; } simulated function OnToggle(SeqAct_Toggle Action) { if (Action.InputLinks[0].bHasImpulse) { OpenDoor(); } else { if (Action.InputLinks[1].bHasImpulse) { CloseDoor(); } else { if (Action.InputLinks[2].bHasImpulse) { ToggleDoor(); } } } } // ScriptText: TextBuffer[26] replication { if (Role == 3 && bNetDirty) DoorState; } defaultproperties { // child object FaceAudioComponent of type AudioComponent // child object SoundComponent0 of type AudioComponent // child object MyLightEnvironment of type DynamicLightEnvironmentComponent // child object SkeletalMeshComponent0 of type SkeletalMeshComponent }
Leave a comment: