diff --git a/UnrealProject/Lost_Edge/Config/DefaultEngine.ini b/UnrealProject/Lost_Edge/Config/DefaultEngine.ini index ab61445..e75e58f 100644 --- a/UnrealProject/Lost_Edge/Config/DefaultEngine.ini +++ b/UnrealProject/Lost_Edge/Config/DefaultEngine.ini @@ -122,26 +122,31 @@ ManualIPAddress= -Profiles=(Name="UI",CollisionEnabled=QueryOnly,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Block),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ",bCanModify=False) +Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision") +Profiles=(Name="BlockAll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=,HelpMessage="WorldStatic object that blocks all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="OverlapAll",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") +Profiles=(Name="BlockAllDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=,HelpMessage="WorldDynamic object that blocks all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="OverlapAllDynamic",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="InteractableTrace",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps all actors by default. All new custom channels will use its own default response. ") +Profiles=(Name="IgnoreOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that ignores Pawn and Vehicle. All other channels will be set to default.") -+Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ") -+Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ") -+Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldStatic"),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.") -+Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.") ++Profiles=(Name="OverlapOnlyPawn",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that overlaps Pawn, Camera, and Vehicle. All other channels will be set to default. ") ++Profiles=(Name="Pawn",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="InteractableTrace")),HelpMessage="Pawn object. Can be used for capsule of any playerable character or AI. ") ++Profiles=(Name="Spectator",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Pawn object that ignores all other actors except WorldStatic.") ++Profiles=(Name="CharacterMesh",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="Pawn",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore)),HelpMessage="Pawn object that is used for Character Mesh. All other channels will be set to default.") +Profiles=(Name="PhysicsActor",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=,HelpMessage="Simulating actors") +Profiles=(Name="Destructible",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Destructible",CustomResponses=,HelpMessage="Destructible actors") +Profiles=(Name="InvisibleWall",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldStatic object that is invisible.") +Profiles=(Name="InvisibleWallDynamic",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore)),HelpMessage="WorldDynamic object that is invisible.") -+Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.") ++Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldDynamic object that is used for trigger. All other channels will be set to default.") +Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.") +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") -+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="Interactable",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Interactable")),HelpMessage="WorldDynamic objects derived from AInteractable.") -+Profiles=(Name="AgeOfWarUnitPlayer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Vehicle",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Interactable")),HelpMessage="Minigame object") -+Profiles=(Name="AgeOfWarUnitComputer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Destructible",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="Interactable")),HelpMessage="Minigame object") -+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="Interactable") ++Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="Interactable",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="InteractableTrace")),HelpMessage="WorldDynamic objects derived from AInteractable.") ++Profiles=(Name="AgeOfWarUnitPlayer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Vehicle",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="InteractableTrace")),HelpMessage="Minigame object") ++Profiles=(Name="AgeOfWarUnitComputer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Destructible",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="InteractableTrace")),HelpMessage="Minigame object") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="InteractableTrace") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Interactable") ++EditProfiles=(Name="Pawn",CustomResponses=((Channel="InteractableTrace"),(Channel="Interactable",Response=ECR_Overlap))) ++EditProfiles=(Name="OverlapAllDynamic",CustomResponses=((Channel="InteractableTrace",Response=ECR_Overlap),(Channel="Interactable",Response=ECR_Overlap))) ++EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Interactable",Response=ECR_Ignore))) ++EditProfiles=(Name="Spectator",CustomResponses=((Channel="Interactable",Response=ECR_Ignore))) -ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall") -ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn") -ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic") @@ -163,6 +168,7 @@ ManualIPAddress= +CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic") +CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle") +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") ++CollisionChannelRedirects=(OldName="Interactable",NewName="InteractableTrace") [/Script/FMODStudio.FMODSettings] bLoadAllBanks=True diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player.uasset index 941b408..519285e 100644 --- a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player.uasset +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58d6cbf633283a9746aaee650d1b09949761b2dc40b9e1c3fb5f1be043737f71 -size 493547 +oid sha256:6084367ea3dee23eeb15351e582cb00648761ed2cdf15e860c344ce67c07325c +size 482658 diff --git a/UnrealProject/Lost_Edge/Content/Levels/Test/Actors/InteractablesTest/BP_Test_InteractableMove.uasset b/UnrealProject/Lost_Edge/Content/Levels/Test/Actors/InteractablesTest/BP_Test_InteractableMove.uasset index 0a4d99b..e6ea1e4 100644 --- a/UnrealProject/Lost_Edge/Content/Levels/Test/Actors/InteractablesTest/BP_Test_InteractableMove.uasset +++ b/UnrealProject/Lost_Edge/Content/Levels/Test/Actors/InteractablesTest/BP_Test_InteractableMove.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14910f5aee379b1202e2112de8f46f3496377b57b40696c3178c992eadfc3a10 -size 20049 +oid sha256:9f5d9771417f1878f2b549ff07766ddd79e3974700802781f559bae576951708 +size 19944 diff --git a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Credits.uasset b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Credits.uasset index 9a34b41..7221566 100644 --- a/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Credits.uasset +++ b/UnrealProject/Lost_Edge/Content/UI/Blueprints/MainMenu/Pages/UI_MainMenu_Page_Credits.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90e4a2d5a8bb2c7736d385ed55c8115997b7ff6c46ea8dbc82625277c2f343f2 -size 122677 +oid sha256:6cd309e0b9aaa4353b5782b8acde7c85aa78797fb2969691b4a1a63cf21c180b +size 117312 diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp index 9103d85..cba940d 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp @@ -24,6 +24,7 @@ UInCameraInteractableActivator::UInCameraInteractableActivator(const FObjectInit capturer->interactableInScreenDelegate.BindUObject(this, &UInCameraInteractableActivator::NewSeenInteractable); capturer->SetupAttachment(this); capturer->scanDistance = scanDistance; + capturer->ignoredActors.Add(actor); PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bStartWithTickEnabled = false; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp index 9059521..8f27b5b 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp @@ -18,8 +18,9 @@ UInteractableActivator::UInteractableActivator(const FObjectInitializer& ObjectI if(HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject)) return; + actor = GetOwner(); world = GetWorld(); - player = Cast(GetOwner()); + player = APlayerBase::Get(); collisionChannel = ECC_GameTraceChannel1; if(auto collisions = UCollisionProfile::Get()) diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h index 0e2c4aa..8384163 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h @@ -46,6 +46,7 @@ protected: UPROPERTY(EditDefaultsOnly) float scanDistance = 250; + class AActor* actor; class UWorld* world; class APlayerBase* player; ECollisionChannel collisionChannel; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp index a5d24d2..51c2ca9 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp @@ -248,6 +248,8 @@ void UInteractableScreenCapturer::Process() FHitResult result{}; FVector startLocation = view.Location; FVector endLocation = worldLoc + worldDir * scanDistance; + FCollisionQueryParams hitParams; + hitParams.AddIgnoredActors(ignoredActors); world->LineTraceSingleByChannel( result, startLocation, diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h index 19a69bf..e4697fc 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h @@ -28,6 +28,8 @@ public: UPROPERTY(EditAnywhere) float scanDistance = 7000; + TArray ignoredActors; + protected: /** Enques render thread task to find obect on screen */ void Process(); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp index 60f10e0..5cfecb5 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp @@ -21,12 +21,15 @@ void URaycastInteractableActivator::Scan_Implementation() FHitResult result; FVector startLocation = GetComponentLocation(); FVector endLocation = startLocation + (GetComponentRotation().Vector() * scanDistance); + FCollisionQueryParams hitParams; + hitParams.AddIgnoredActor(actor); world->LineTraceSingleByChannel( result, startLocation, endLocation, - collisionChannel + collisionChannel, + hitParams ); if(result.bBlockingHit) diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp index 0f09ddf..1b9837b 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.cpp @@ -2,6 +2,7 @@ #include "Interactable.h" +#include "Engine/CollisionProfile.h" #include "Kismet/GameplayStatics.h" #include "Activators/InteractableActivator.h" @@ -11,6 +12,15 @@ #include "PlayerBase.h" #include "Widgets/WidgetsManager.h" +#include + +namespace +{ + constexpr auto collisionProfile = TEXT("Interactable"); + constexpr int32 sawStencil = 128; + constexpr int32 outlineStencil = 132; +} + TSet> AInteractable::interactionActivators = {}; TSet> AInteractable::interactionModificators = {}; @@ -33,6 +43,19 @@ void AInteractable::AppendModificatorClass(TSubclassOf collisionTemplate; + if(!collisionTemplate.has_value()) + { + FCollisionResponseTemplate buffer; + UCollisionProfile::Get()->GetProfileTemplate(collisionProfile, buffer); + collisionTemplate = buffer; + } + + return collisionTemplate->ObjectType; +} + int32 AInteractable::GetActivatedFlags() { return activated; @@ -83,12 +106,12 @@ void AInteractable::BeginPlay() { if(activatorTypes) { - collision->SetCollisionProfileName(TEXT("Interactable")); + collision->SetCollisionProfileName(collisionProfile); } if(activatorTypes & static_cast(EActivatorType::Saw)) { - collision->CustomDepthStencilValue = 128; + collision->CustomDepthStencilValue = sawStencil; collision->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; collision->SetRenderCustomDepth(true); } @@ -144,7 +167,7 @@ void AInteractable::Activate(EActivatorType type) if(activated & static_cast(EActivatorType::Use)) { for(auto collision : collisions) - collision->SetCustomDepthStencilValue(132); + collision->SetCustomDepthStencilValue(outlineStencil); } OnActivate(type); @@ -178,8 +201,12 @@ void AInteractable::Deactivate(EActivatorType type) if(!(activated & static_cast(EActivatorType::Use))) { - for(auto collision : collisions) - collision->SetCustomDepthStencilValue(0); + if(modificators.Contains(EActivatorType::Saw)) + for(auto collision : collisions) + collision->SetCustomDepthStencilValue(sawStencil); + else + for(auto collision : collisions) + collision->SetCustomDepthStencilValue(0); } OnDeactivate(type); diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h index 9a977c3..6f95095 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Interactable.h @@ -43,6 +43,8 @@ public: static void AppendActivatorClass(TSubclassOf activator); static void AppendModificatorClass(TSubclassOf modificator); + static ECollisionChannel GetCollisionChannel(); + /** Interactables shared cache */ static TSet> interactionActivators; static TSet> interactionModificators; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.cpp index a38c87f..d60234b 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.cpp @@ -2,8 +2,12 @@ #include "MoveInteractableModificator.h" +#include "Components/BoxComponent.h" +#include "Components/CapsuleComponent.h" +#include "Components/PrimitiveComponent.h" #include "EnhancedInputComponent.h" #include "InputMappingContext.h" +#include "PhysicsEngine/PhysicsHandleComponent.h" #include "Interactable/Interactable.h" #include "MainGameModeBase.h" @@ -20,6 +24,11 @@ UMoveInteractableModificator::UMoveInteractableModificator(const FObjectInitiali inputMapping = asset.Object; actor = Cast(GetOwner()); + if(actor) + { + shape = FCollisionShape::MakeBox(actor->GetComponentsBoundingBox().GetExtent()); + primitive = actor->GetComponentByClass(); + } PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bStartWithTickEnabled = false; @@ -70,7 +79,7 @@ void UMoveInteractableModificator::Bind_Implementation(class UEnhancedInputCompo } lastInput = input; - player = Cast(Cast(lastInput->GetOwner())->GetPawn()); + player = APlayerBase::Get(); SetComponentTickEnabled(true); OnMoveActivated.Broadcast(); @@ -98,6 +107,16 @@ void UMoveInteractableModificator::TurnOnHolding() { FScopeLock lock1(&critical); holding = true; + if(primitive && primitive->IsSimulatingPhysics()) + { + positionUpdateType = PositionUpdateType::Physics; + player->physicsHandle->GrabComponentAtLocationWithRotation(primitive, TEXT("None"), actor->GetActorLocation(), actor->GetActorRotation()); + } + else + { + positionUpdateType = PositionUpdateType::Simple; + } + ProcessState(); distance = (player->GetCameraLocation() - actor->GetActorLocation()).Length(); AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::Hold); @@ -107,6 +126,8 @@ void UMoveInteractableModificator::TurnOffHolding() { FScopeLock lock1(&critical); holding = false; + if(positionUpdateType == PositionUpdateType::Physics) + player->physicsHandle->ReleaseComponent(); ProcessState(); AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::Unhold); } @@ -139,6 +160,11 @@ void UMoveInteractableModificator::ProcessState() else { actor->activationLockers.Remove(this); + if(indicating) + { + indicating = false; + AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::TurnOffIndication); + } if((actor->GetActivatedFlags() & static_cast(GetActivatorTypes())) == 0 && !bindindingHandlers.IsEmpty()) { @@ -152,27 +178,42 @@ void UMoveInteractableModificator::UpdatePosition() if(!player || (!holding && !rotating)) return; + if(player->IsOverlappingActor(actor)) + return; + auto camLoc = player->GetCameraLocation(); auto dir = player->GetCameraDirection(); auto newLoc = camLoc + dir * distance; - auto oldLoc = actor->GetActorLocation(); - //auto interpLoc = FMath::VInterpTo(oldLoc, newLoc, GetWorld()->GetDeltaSeconds(), 20.0f); - //auto interpLoc = FMath::Lerp(oldLoc, newLoc, 0.5f); - FHitResult hit; - actor->SetActorLocation(newLoc, true, &hit, ETeleportType::None); - static bool indicating = false; - if(hit.bBlockingHit && !indicating) + auto rot = actor->GetActorQuat(); + bool blocked = MoveIsBlocked(newLoc, rot) || player->nearScanner->ComponentOverlapComponent(primitive, newLoc, actor->GetActorQuat(), {}); + if(blocked) { - indicating = true; - AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::TurnOnIndication); + if(!indicating) + { + indicating = true; + AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::TurnOnIndication); + } + return; } - else if(!hit.bBlockingHit && indicating) + else { - indicating = false; - AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::TurnOffIndication); + if(indicating) + { + indicating = false; + AMainGameModeBase::GetWidgetsManager()->AnimateInteractionHint(this, 0, EInputAnimatedWidgetAnimation::TurnOffIndication); + } } + switch(positionUpdateType) + { + case PositionUpdateType::Physics: + player->physicsHandle->SetTargetLocation(newLoc); + break; + default: + actor->SetActorLocation(newLoc, true, nullptr, ETeleportType::None); + break; + } } void UMoveInteractableModificator::Zooming(const FInputActionValue& value) @@ -180,8 +221,14 @@ void UMoveInteractableModificator::Zooming(const FInputActionValue& value) if(!holding && !rotating) return; - distance += value.Get() * zoomSpeed; - distance = FMath::Clamp(distance, minDistance, maxDistance); + float delta = value.Get() * zoomSpeed; + auto start = actor->GetActorLocation(); + auto end = start + player->GetCameraDirection() * delta; + auto rot = actor->GetActorQuat(); + if(MoveIsBlocked(end, rot)) + return; + + distance = FMath::Clamp(distance + delta, minDistance, maxDistance); } void UMoveInteractableModificator::Rotating(const FInputActionValue& axis) @@ -190,9 +237,35 @@ void UMoveInteractableModificator::Rotating(const FInputActionValue& axis) return; auto v = axis.Get(); - auto vec = player->GetCameraDirection(); - auto currentRot = actor->GetActorRotation(); - auto currentLoc = actor->GetActorLocation(); - auto newRot = FRotator{ v.Y * vec.X, v.X, v.Y * vec.Y * -1 }; - actor->AddActorWorldRotation(newRot, true, nullptr, ETeleportType::None); // sweep not supported from 4.xx+ -} \ No newline at end of file + auto dir = player->GetCameraDirection(); + auto addRot = FRotator{ v.Y * dir.X, v.X, v.Y * dir.Y * -1 }; + auto newRot = (addRot.Quaternion() * actor->GetActorQuat()).Rotator(); + // rotation sweep is unsupported for some reason + // if(MoveIsBlocked(actor->GetActorLocation(), newRot.Quaternion())) + // return; + + if(player->nearScanner->ComponentOverlapComponent(primitive, actor->GetActorLocation(), newRot, {}) + || player->feetScanner->ComponentOverlapComponent(primitive, actor->GetActorLocation(), newRot, {})) + return; + + switch(positionUpdateType) + { + case PositionUpdateType::Physics: + player->physicsHandle->SetTargetRotation(newRot); + break; + default: + actor->SetActorRotation(newRot, ETeleportType::None); + break; + } +} + +bool UMoveInteractableModificator::MoveIsBlocked(const FVector& end, const FQuat& rot) +{ + FHitResult hit; + FVector start = actor->GetActorLocation(); + FCollisionQueryParams hitParams; + hitParams.AddIgnoredActor(actor); + actor->GetWorld()->SweepSingleByChannel(hit, start, end, rot, AInteractable::GetCollisionChannel(), shape, hitParams); + + return hit.bBlockingHit; +} diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.h index d50e920..d6071a6 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/Interactable/Modificators/MoveInteractableModificator.h @@ -53,6 +53,7 @@ private: void UpdatePosition(); void Zooming(const FInputActionValue& value); void Rotating(const FInputActionValue& axis); + bool MoveIsBlocked(const FVector& end, const FQuat& rot); class UEnhancedInputComponent* lastInput = nullptr; TArray bindindingHandlers; @@ -61,4 +62,13 @@ private: class AInteractable* actor = nullptr; class APlayerBase* player = nullptr; FCriticalSection critical; + bool indicating = false; + FCollisionShape shape; + class UPrimitiveComponent* primitive; + + enum PositionUpdateType : uint8 + { + Simple, + Physics + } positionUpdateType = Simple; }; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.cpp index d9ca437..cc24fdb 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.cpp @@ -3,11 +3,14 @@ #include "PlayerBase.h" #include "Camera/CameraComponent.h" +#include "Components/BoxComponent.h" +#include "Components/CapsuleComponent.h" #include "GameFramework/CharacterMovementComponent.h" #include "GameFramework/SpringArmComponent.h" #include "InputMappingContext.h" #include "Kismet/GameplayStatics.h" #include "Kismet/KismetMathLibrary.h" +#include "PhysicsEngine/PhysicsHandleComponent.h" #include "CustomGameSettings.h" #include "CustomPlayerController.h" @@ -40,6 +43,12 @@ APlayerBase::APlayerBase() itemDropSpringArm = CreateDefaultSubobject(TEXT("ItemDropSpringArm")); itemDropSpringArm->TargetArmLength = -200; itemDropSpringArm->SetupAttachment(camera); + + physicsHandle = CreateDefaultSubobject(TEXT("PhysicsHandle")); + nearScanner = CreateDefaultSubobject(TEXT("NearScanner")); + nearScanner->SetupAttachment(RootComponent); + feetScanner = CreateDefaultSubobject(TEXT("FeetScanner")); + feetScanner->SetupAttachment(RootComponent); } void APlayerBase::Tick(float DeltaTime) @@ -195,6 +204,10 @@ void APlayerBase::Jump() if(jumpLocked) return; + if(auto primitive = physicsHandle->GetGrabbedComponent()) + if(feetScanner->ComponentOverlapComponent(primitive, primitive->GetComponentLocation(), primitive->GetComponentRotation(), {})) + return; + ACharacter::Jump(); } diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.h index 63aa4da..0a59165 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/PlayerBase.h @@ -80,9 +80,18 @@ public: FVector moveVector; + UPROPERTY() class AActor* leftPocketItem = nullptr; + UPROPERTY() class AActor* rightPocketItem = nullptr; + UPROPERTY() + class UPhysicsHandleComponent* physicsHandle; + UPROPERTY(EditAnywhere) + class UCapsuleComponent* nearScanner; + UPROPERTY(EditAnywhere) + class UBoxComponent* feetScanner; + protected: virtual void BeginPlay() override;