Initial commit

This commit is contained in:
theOneEmployee 2020-10-08 15:33:58 +02:00
commit 8c1bfa9f75
41 changed files with 788 additions and 0 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
Binaries
DerivedDataCache
Intermediate
Saved
.vscode
.vs
*.VC.db
*.opensdf
*.opendb
*.sdf
*.sln
*.suo
*.xcodeproj
*.xcworkspace

17
BuildingEscape.uproject Normal file
View File

@ -0,0 +1,17 @@
{
"FileVersion": 3,
"EngineAssociation": "4.22",
"Category": "",
"Description": "",
"Enterprise": true,
"Modules": [
{
"Name": "BuildingEscape",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
]
}

2
Config/DefaultEditor.ini Normal file
View File

@ -0,0 +1,2 @@

63
Config/DefaultEngine.ini Normal file
View File

@ -0,0 +1,63 @@
[URL]
[/Script/Engine.RendererSettings]
r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Levels/BuildingEscape.BuildingEscape
GameDefaultMap=/Game/Levels/BuildingEscape.BuildingEscape
GlobalDefaultGameMode=/Game/Blueprints/MyBuildingEscapeGameModeBase_BP.MyBuildingEscapeGameModeBase_BP_C
[/Script/Engine.Engine]
bUseFixedFrameRate=True
FixedFrameRate=60.000000
[/Script/Engine.PhysicsSettings]
DefaultGravityZ=-980.000000
DefaultTerminalVelocity=4000.000000
DefaultFluidFriction=0.300000
SimulateScratchMemorySize=262144
RagdollAggregateThreshold=4
TriangleMeshTriangleMinAreaThreshold=5.000000
bEnableShapeSharing=False
bEnablePCM=True
bEnableStabilization=False
bWarnMissingLocks=True
bEnable2DPhysics=False
PhysicErrorCorrection=(PingExtrapolation=0.100000,PingLimit=100.000000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,MaxLinearHardSnapDistance=400.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000)
LockedAxis=Invalid
DefaultDegreesOfFreedom=Full3D
BounceThresholdVelocity=200.000000
FrictionCombineMode=Average
RestitutionCombineMode=Average
MaxAngularVelocity=3600.000000
MaxDepenetrationVelocity=0.000000
ContactOffsetMultiplier=0.020000
MinContactOffset=2.000000
MaxContactOffset=8.000000
bSimulateSkeletalMeshOnDedicatedServer=True
DefaultShapeComplexity=CTF_UseSimpleAndComplex
bDefaultHasComplexCollision=True
bSuppressFaceRemapTable=False
bSupportUVFromHitResults=False
bDisableActiveActors=False
bDisableKinematicStaticPairs=False
bDisableKinematicKinematicPairs=False
bDisableCCD=False
bEnableEnhancedDeterminism=False
MaxPhysicsDeltaTime=0.033333
bSubstepping=False
bSubsteppingAsync=False
MaxSubstepDeltaTime=0.016667
MaxSubsteps=6
SyncSceneSmoothingFactor=0.000000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)

2
Config/DefaultGame.ini Normal file
View File

@ -0,0 +1,2 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=ACCA80D7484FF60AFDD85690697A2DA6

52
Config/DefaultInput.ini Normal file
View File

@ -0,0 +1,52 @@
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
bCaptureMouseOnLaunch=True
bDefaultViewportMouseLock=False
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False
bUseAutocorrect=False
DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
DefaultViewportMouseLockMode=LockOnCapture
FOVScale=0.011110
DoubleClickTime=0.200000
+ActionMappings=(ActionName="Grab",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde
+ConsoleKeys=Caret

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# BuildingEscape
Developed with Unreal Engine 4

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class BuildingEscapeTarget : TargetRules
{
public BuildingEscapeTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
ExtraModuleNames.AddRange( new string[] { "BuildingEscape" } );
}
}

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class BuildingEscape : ModuleRules
{
public BuildingEscape(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BuildingEscape.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, BuildingEscape, "BuildingEscape" );

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BuildingEscapeGameModeBase.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "BuildingEscapeGameModeBase.generated.h"
/**
*
*/
UCLASS()
class BUILDINGESCAPE_API ABuildingEscapeGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};

View File

@ -0,0 +1,181 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "DrawDebugHelpers.h"
#include "Engine/World.h"
#include "GameFramework/PlayerController.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.h"
#define OUT //mark for outparameters (only for reading purposes)
// 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();
FindPhysicsHandle(); //Check for physics Handle Component
SetupInputComponent();
}
void UGrabber::FindPhysicsHandle()
{
PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>(); //<> for function templates
if(!PhysicsHandle) // same as if(PhysicsHandle == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("No Physics handle component found on: %s !"), *GetOwner()->GetName());
}
}
void UGrabber::SetupInputComponent()
{
InputComponent = GetOwner()->FindComponentByClass<UInputComponent>();
if(InputComponent)
{
//UE_LOG(LogTemp, Warning, TEXT("Input Component found on: %s !"), *GetOwner()->GetName());
InputComponent->BindAction("Grab", IE_Pressed, this, &UGrabber::Grab); // User Input zu einem funktionsaufruf binden // Name der funktion beim keypress gleich name vom action in projectsettings , IE = InputEvent
InputComponent->BindAction("Grab", IE_Released, this, &UGrabber::GrabRelease);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Input Component MISSING on: %s !"), *GetOwner()->GetName());
}
}
void UGrabber::Grab()
{
//only Raycast, when key is pressed and Try and reach any actor with physics body collision set.
FHitResult HitResult = GetFirstPhysicsBodyInReach();
UPrimitiveComponent* ComponentToGrab = HitResult.GetComponent();
AActor* ActorHit = HitResult.GetActor();
//if we hit something, attach physics handle
if(ActorHit) //if an actor is hit, then attach PhysicsHandle
{
if(!PhysicsHandle){return;}
PhysicsHandle->GrabComponentAtLocation
(
ComponentToGrab,
NAME_None,
GetLineTraceEnd()
);
}
}
void UGrabber::GrabRelease()
{
//Remove, release physicshandle
if(!PhysicsHandle){return;}
PhysicsHandle->ReleaseComponent();
}
// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if(!PhysicsHandle){return;}
//If PhysicsBody attached
if(PhysicsHandle->GrabbedComponent)
{
//move object we are holding
PhysicsHandle->SetTargetLocation(GetLineTraceEnd());
}
}
FHitResult UGrabber::GetFirstPhysicsBodyInReach() const
{
FHitResult Hit;
//Raycast out to a certain distance (Reach)
FCollisionQueryParams TraceParams(FName(TEXT("")), false, GetOwner()); //fname, ComplexCollision=false, ignore hit on owner(origin point)
GetWorld()->LineTraceSingleByObjectType(
OUT Hit,
GetPlayerWorldPosition(), //PlayerViewPointLocation
GetLineTraceEnd(),
FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody), //:: to accsess an enum
TraceParams
);
return Hit;
}
FVector UGrabber::GetPlayerWorldPosition() const
{
//Get Player Viewport
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);
return PlayerViewPointLocation;
}
FVector UGrabber::GetLineTraceEnd() const //Players Reach
{
//Get Player Viewport
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);
return PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;
}
//comments
//Logging out to test
// UE_LOG(LogTemp, Warning, TEXT("Location: %s, Rotation= %s"),
// *PlayerViewPointLocation.ToString(),
// *PlayerViewPointRotation.ToString()
// );
/*
//Get Player Viewport
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);
//GetPhysicsbodyInReach
//Draw a Line from the Player showing the Reach
FVector LineTraceEnd = PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;
// DEBUG
// DrawDebugLine(
// GetWorld(),
// PlayerViewPointLocation,
// LineTraceEnd,
// FColor(0, 255 , 0) //red, green, blue,
// false,
// 0.f,
// 0,
// 5.f
// );
*/
//return name of hit actor
//See what it hits
// if(Hit.GetActor())
// UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *Hit.GetActor()->GetName());
//or
/*
AActor* ActorHit = Hit.GetActor();
//Log out to Test
if(Hit.GetActor())
{
UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *ActorHit->GetName());
}
*/

View File

@ -0,0 +1,50 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UGrabber();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
// Called when the game starts
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere)
float Reach = 100.f;
UPROPERTY() //Everything with a U has a UPROPERTY
UPhysicsHandleComponent* PhysicsHandle = nullptr; //protection against crashes
UPROPERTY()
UInputComponent* InputComponent = nullptr;
void Grab();
void GrabRelease();
void FindPhysicsHandle();
void SetupInputComponent();
//return the first Actor in Reach with physicsbody
FHitResult GetFirstPhysicsBodyInReach() const;
//Return Players Line Trace End
FVector GetLineTraceEnd() const; // playersReach
//Get Players Position in the World
FVector GetPlayerWorldPosition() const;
};

View File

@ -0,0 +1,157 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "OpenDoor.h"
#include "Components/AudioComponent.h"
#include "Components/PrimitiveComponent.h"
#include "Engine/World.h"
#include "GameFramework/Actor.h"
#include "GameFramework/PlayerController.h"
#define OUT
// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
// 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 UOpenDoor::BeginPlay()
{
Super::BeginPlay();
InitialYaw = GetOwner()->GetActorRotation().Yaw;
CurrentYaw = InitialYaw;
TargetAngleOfOpenDoor += InitialYaw;
FindPressurePlateComponent();
FindAudioComponent();
//ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
}
void UOpenDoor::FindAudioComponent()
{
AudioComponent = GetOwner()->FindComponentByClass<UAudioComponent>(); //<> for function templates
if(!AudioComponent) // same as if(PhysicsHandle == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("No Audio component found on: %s !"), *GetOwner()->GetName());
}
}
void UOpenDoor::FindPressurePlateComponent()
{
if(!PressurePlate)
{
UE_LOG(LogTemp, Error, TEXT("%s has OpenDoor on it, but no PressurePlate set!"), *GetOwner()->GetName());
}
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
//if(PressurePlate->IsOverlappingActor(ActorThatOpens)) // kann nullpointer + UE4 crash geben
//if(PressurePlate && PressurePlate->IsOverlappingActor(ActorThatOpens)) //prüft erst, ob es ein actor gibt
if(TotalMass() > MassToOpenDoor)
{
OpenDoor(DeltaTime);
//DoorLastOpened When the door was opened
DoorLastOpened = GetWorld()->GetTimeSeconds();;
}
else
{
//if door has been open longer than DoorCloseDelay
//if(GetWorld()->GetTimeSeconds() > DoorLastOpened + DoorDelay)
if(GetWorld()->GetTimeSeconds() - DoorLastOpened > DoorDelay)
CloseDoor(DeltaTime);
}
}
void UOpenDoor::OpenDoor(float DeltaTime)
{
FRotator DoorRotation = GetOwner()->GetActorRotation();
//CurrentYaw = FMath::FInterpTo(CurrentYaw, TargetYaw, DeltaTime, 2.f);
CurrentYaw = FMath::Lerp(CurrentYaw, TargetAngleOfOpenDoor, DeltaTime * OpenDoorRotationSpeed); //complex Interpolation
DoorRotation.Yaw = CurrentYaw;
GetOwner()->SetActorRotation(DoorRotation);
CloseDoorSoundHasBeenPlayed = false;
if(!AudioComponent){return;}
if(!OpenDoorSoundHasBeenPlayed)
{
AudioComponent->Play();
OpenDoorSoundHasBeenPlayed = true;
}
}
void UOpenDoor::CloseDoor(float DeltaTime)
{
FRotator DoorRotation = GetOwner()->GetActorRotation();
CurrentYaw = FMath::Lerp(CurrentYaw, InitialYaw, DeltaTime * CloseDoorRotationSpeed);
DoorRotation.Yaw = CurrentYaw;
GetOwner()->SetActorRotation(DoorRotation);
OpenDoorSoundHasBeenPlayed = false;
if(!AudioComponent){return;}
if(!CloseDoorSoundHasBeenPlayed)
{
AudioComponent->Play();
CloseDoorSoundHasBeenPlayed = true;
}
}
float UOpenDoor::TotalMass() const
{
float TotalMass = 0.f;
//find All Overlapping Actors
TArray<AActor*> OverlapingActors;
if (!PressurePlate){return TotalMass;}
PressurePlate->GetOverlappingActors(OUT OverlapingActors);
//Add Up Their Masses
for(AActor* Actor : OverlapingActors)
{
TotalMass += Actor -> FindComponentByClass<UPrimitiveComponent>()->GetMass();
UE_LOG(LogTemp, Warning, TEXT("%s is on the pressureplate"), *Actor->GetName());
}
return TotalMass;
}
//Notes
//UE_LOG(LogTemp, Warning, TEXT("%f"), TargetYaw);
// UE_LOG(LogTemp, Warning, TEXT("%s"), *GetOwner()->GetActorRotation().ToString());
// UE_LOG(LogTemp, Warning, TEXT("The Yaw is: %f"), GetOwner()->GetActorRotation().Yaw);
// FRotator CurrentRotation = GetOwner()->GetActorRotation();
// FMath::Lerp(CurrentRotation, FRotator(0.f,90.f,0.f), 0.2f);
// GetOwner()->SetActorRotation(CurrentRotation);
// UE_LOG(LogTemp, Warning, TEXT("The Yaw is: %f"), CurrentRotation.Yaw);
//TargetYaw = 90.f;
// FRotator OpenDoor(0.f, 0.f, 0.f);
// //OpenDoor.Yaw = FMath::Lerp(CurrentYaw, TargetYaw, 0.02f); //complex Interpolation
// OpenDoor.Yaw = FMath::FInterpTo(CurrentYaw, TargetYaw, DeltaTime, 2.f);//complex Interpolation Framerate unabhängig wegen Deltatime
// //OpenDoor.Yaw = FMath::FInterpConstantTo(CurrentYaw, TargetYaw, DeltaTime, 0.02f); //lineare interpolation
// GetOwner()->SetActorRotation(OpenDoor);
//float f = 10.f;
//FRotator CurrentRotation = GetOwner()->GetActorRotation();
//FRotator Rotation = FRotator(0.f, -90.f, 0.f);
//FRotator OpenDoor={float,float,float}
//FRotator OpenDoor{float,float,float}
//FRotator OpenDoor(float,float,float)
//CurrentRotation.Yaw = 90.f;
//GetOwner()->SetActorRotation(CurrentRotation);

View File

@ -0,0 +1,71 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/AudioComponent.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
//#include "Engine/ActorChannel.h"
#include "OpenDoor.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UOpenDoor();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void OpenDoor(float DeltaTime);
void CloseDoor(float DeltaTime);
float TotalMass() const;
void FindAudioComponent();
void FindPressurePlateComponent();
//Tracks if Sound has been Played
bool OpenDoorSoundHasBeenPlayed = false;
bool CloseDoorSoundHasBeenPlayed = true;
private:
float InitialYaw;
float CurrentYaw;
float DoorLastOpened = 0.f;
bool HasSoundBeenPlayed = false;
UPROPERTY(EditAnywhere)
float MassToOpenDoor = 50.f;
UPROPERTY(EditAnywhere)
float TargetAngleOfOpenDoor =90.f;
UPROPERTY(EditAnywhere)
float OpenDoorRotationSpeed = 2.f;
UPROPERTY(EditAnywhere)
float CloseDoorRotationSpeed = 0.5f;
UPROPERTY(EditAnywhere)
float DoorDelay = 2.f; //2 second delay
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate = nullptr;
UPROPERTY(EditAnywhere)
AActor* ActorThatOpens = nullptr;
UPROPERTY()
UAudioComponent* AudioComponent = nullptr;
};

View File

@ -0,0 +1,63 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "WorldPosition.h"
#include "GameFramework/Actor.h"
// Sets default values for this component's properties
UWorldPosition::UWorldPosition()
{
// 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 UWorldPosition::BeginPlay()
{
Super::BeginPlay();
// ...
FString ObjectName = GetOwner()->GetName();
FString ObjectPosition = GetOwner()->GetActorLocation().ToString();
UE_LOG(LogTemp, Warning, TEXT("%s"), *ObjectName);
UE_LOG(LogTemp, Warning, TEXT("%s"), *ObjectPosition);
UE_LOG(LogTemp, Warning, TEXT("My name is: %s"), *GetOwner()->GetName());
UE_LOG(LogTemp, Warning, TEXT("My worldPosition is: %s"), *GetOwner()->GetActorLocation().ToString());
}
// Called every frame
void UWorldPosition::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
//comment
//part 1
// UE_LOG(LogTemp, Warning, TEXT("This is a Warning"));
// UE_LOG(LogTemp, Error, TEXT("This is an Error"));
// UE_LOG(LogTemp, Display, TEXT("This is a Normal Message"));
// FString Log = TEXT("Hello");
// FString* LogPtr = &Log;
// Log.Len();
// (*LogPtr).Len(); // .Len wird zuerst ausgeführt, damit variable erreichbar () benutzen
// LogPtr->Len(); // -> zum aufruf von methoden von werten auf den pointer zeigen
// UE_LOG(LogTemp, Warning, TEXT("%s"), *Log);
// UE_LOG(LogTemp, Warning, TEXT("%s"), **LogPtr);
// FString OwnerName = GetOwner()->GetName();
// UE_LOG(LogTemp, Warning, TEXT("%s"), *OwnerName);
// UE_LOG(LogTemp, Warning, TEXT("My name is: %s"), *GetOwner()->GetName());

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "WorldPosition.generated.h" // muss unten sein
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UWorldPosition : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UWorldPosition();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class BuildingEscapeEditorTarget : TargetRules
{
public BuildingEscapeEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
ExtraModuleNames.AddRange( new string[] { "BuildingEscape" } );
}
}