diff --git a/RoomEscape/Config/DefaultEditor.ini b/RoomEscape/Config/DefaultEditor.ini index e69de29..139597f 100644 --- a/RoomEscape/Config/DefaultEditor.ini +++ b/RoomEscape/Config/DefaultEditor.ini @@ -0,0 +1,2 @@ + + diff --git a/RoomEscape/Config/DefaultEngine.ini b/RoomEscape/Config/DefaultEngine.ini index 63c5815..95216cf 100644 --- a/RoomEscape/Config/DefaultEngine.ini +++ b/RoomEscape/Config/DefaultEngine.ini @@ -2,7 +2,7 @@ [/Script/EngineSettings.GameMapsSettings] EditorStartupMap=/Game/NewMap.NewMap GameDefaultMap=/Game/NewMap.NewMap -GlobalDefaultGameMode=/Script/RoomEscape.RoomEscapeGameModeBase +GlobalDefaultGameMode=/Game/MyRoomEscapeGameModeBase_BP.MyRoomEscapeGameModeBase_BP_C [/Script/HardwareTargeting.HardwareTargetingSettings] TargetedHardwareClass=Desktop @@ -51,3 +51,4 @@ AsyncSceneSmoothingFactor=0.990000 InitialAverageFrameRate=0.016667 PhysXTreeRebuildRate=10 + diff --git a/RoomEscape/Content/DefaultPawn_BP.uasset b/RoomEscape/Content/DefaultPawn_BP.uasset new file mode 100644 index 0000000..a213093 Binary files /dev/null and b/RoomEscape/Content/DefaultPawn_BP.uasset differ diff --git a/RoomEscape/Content/MyRoomEscapeGameModeBase_BP.uasset b/RoomEscape/Content/MyRoomEscapeGameModeBase_BP.uasset new file mode 100644 index 0000000..aa76ce6 Binary files /dev/null and b/RoomEscape/Content/MyRoomEscapeGameModeBase_BP.uasset differ diff --git a/RoomEscape/Content/NewMap.umap b/RoomEscape/Content/NewMap.umap index 3aa8c7e..d643376 100644 Binary files a/RoomEscape/Content/NewMap.umap and b/RoomEscape/Content/NewMap.umap differ diff --git a/RoomEscape/Content/NewMap_BuiltData.uasset b/RoomEscape/Content/NewMap_BuiltData.uasset index 0e5dc29..6273f8c 100644 Binary files a/RoomEscape/Content/NewMap_BuiltData.uasset and b/RoomEscape/Content/NewMap_BuiltData.uasset differ diff --git a/RoomEscape/Source/RoomEscape/Grabber.cpp b/RoomEscape/Source/RoomEscape/Grabber.cpp new file mode 100644 index 0000000..e2baba8 --- /dev/null +++ b/RoomEscape/Source/RoomEscape/Grabber.cpp @@ -0,0 +1,33 @@ +// Tyrel Souza 2018 + +#include "Grabber.h" + + +// Sets default values for this component's properties +UGrabber::UGrabber() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = true; + +} + + +// Called when the game starts +void UGrabber::BeginPlay() +{ + Super::BeginPlay(); + UE_LOG(LogTemp, Warning, TEXT("Grabber beginPlay")); + +} + + +// Called every frame +void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + + +} + diff --git a/RoomEscape/Source/RoomEscape/Grabber.h b/RoomEscape/Source/RoomEscape/Grabber.h new file mode 100644 index 0000000..29b199e --- /dev/null +++ b/RoomEscape/Source/RoomEscape/Grabber.h @@ -0,0 +1,29 @@ +// Tyrel Souza 2018 + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "Grabber.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class ROOMESCAPE_API UGrabber : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UGrabber(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + + +}; diff --git a/RoomEscape/Source/RoomEscape/OpenDoor.cpp b/RoomEscape/Source/RoomEscape/OpenDoor.cpp index 656adf6..f558f84 100644 --- a/RoomEscape/Source/RoomEscape/OpenDoor.cpp +++ b/RoomEscape/Source/RoomEscape/OpenDoor.cpp @@ -19,28 +19,37 @@ UOpenDoor::UOpenDoor() void UOpenDoor::BeginPlay() { Super::BeginPlay(); + OwningDoor = GetOwner(); ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn(); } void UOpenDoor::OpenDoor() { - AActor* Owner = GetOwner(); - FString ObjectName = Owner->GetName(); - FString Rot = Owner->GetTransform().GetRotation().GetAxisZ().ToString(); - FRotator NewRotation = FRotator(0.0f, -90.0f, 0.0f); - Owner->SetActorRotation(NewRotation); + FString Rot = OwningDoor->GetTransform().GetRotation().GetAxisZ().ToString(); + OwningDoor->SetActorRotation(FRotator(0.0f, OpenAngle, 0.0f)); +} + +void UOpenDoor::CloseDoor() { + FString Rot = OwningDoor->GetTransform().GetRotation().GetAxisZ().ToString(); + OwningDoor->SetActorRotation(FRotator(0.0f, 0.0f, 0.0f)); } // Called every frame void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - + float CurSeconds = GetWorld()->GetTimeSeconds(); // poll the TriggerVolume every frame // if ActorThatOpens is in the volume, open door if (PressurePlate->IsOverlappingActor(ActorThatOpens)) { OpenDoor(); + LastDoorOpenTime = CurSeconds; + } + + //check if time to close door + if (CurSeconds > LastDoorOpenTime + DoorCloseDelay) { + CloseDoor(); } } diff --git a/RoomEscape/Source/RoomEscape/OpenDoor.h b/RoomEscape/Source/RoomEscape/OpenDoor.h index 8a45b2c..02e98c9 100644 --- a/RoomEscape/Source/RoomEscape/OpenDoor.h +++ b/RoomEscape/Source/RoomEscape/OpenDoor.h @@ -18,21 +18,26 @@ public: // Sets default values for this component's properties UOpenDoor(); void OpenDoor(); + void CloseDoor(); + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; protected: // Called when the game starts virtual void BeginPlay() override; -public: - // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; - private: - UPROPERTY(VisibleAnywhere) - float OpenAngle = 90.f; + UPROPERTY(EditAnywhere) + float OpenAngle = -90.f; UPROPERTY(EditAnywhere) ATriggerVolume* PressurePlate; + + UPROPERTY(EditAnywhere) + float DoorCloseDelay = 1.f; + + float LastDoorOpenTime; AActor* ActorThatOpens; + AActor* OwningDoor; + };