Skip to content

Commit

Permalink
Merge pull request #56 from MashdorDev/FindingTheFun
Browse files Browse the repository at this point in the history
Pull Splitting Mechanic Prototype
  • Loading branch information
GageM authored Feb 8, 2024
2 parents 95b8f9a + b2ecb75 commit ebdeb94
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 15 deletions.
12 changes: 11 additions & 1 deletion Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@


[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Engine/Maps/Templates/Template_Default.Template_Default
EditorStartupMap=/Engine/Maps/Templates/Template_Default.Template_Default
LocalMapOptions=
TransitionMap=None
bUseSplitscreen=True
TwoPlayerSplitscreenLayout=Horizontal
ThreePlayerSplitscreenLayout=FavorTop
FourPlayerSplitscreenLayout=Grid
bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/Engine.GameInstance
GameDefaultMap=/Engine/Maps/Templates/Template_Default.Template_Default
ServerDefaultMap=/Engine/Maps/Entry.Entry
GlobalDefaultGameMode=/Game/Unbread/Core/GameModes/BP_GameMode.BP_GameMode_C
GlobalDefaultServerGameMode=None

[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
Expand Down
3 changes: 3 additions & 0 deletions Content/Unbread/Art/Environment_Assets/Oven_10x6.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Materials/M_Diffuse_Material.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Materials/M_Shiny_Material.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Core/Character/BP_Character.uasset
Git LFS file not shown
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Core/GameModes/BP_GameMode.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Unbread/Environment/Hazards/BP_TestKillVolume.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Unbread/Maps/BlockoutLevelTest.umap
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Maps/CharacterTest01.umap
Git LFS file not shown
14 changes: 13 additions & 1 deletion Source/unbread/DynamicCameraComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,28 @@ void UDynamicCameraComponent::SetNextCamera(AActor* CameraActor)
// Transitions to the next camera
void UDynamicCameraComponent::TransitionCamera(const float TransitionTime)
{


// Do nothing if there is no camera actor to transition to
if(NextCameraActor == nullptr)
{
return;
if(DefaultCameraActor == nullptr)
{
return;
}

NextCameraActor = DefaultCameraActor;
}

UGameplayStatics::GetPlayerController(GetWorld(), 0)->DisableInput(UGameplayStatics::GetPlayerController(GetWorld(), 0));

// Transition to the NextCameraActor
UGameplayStatics::GetPlayerController(GetWorld(), 0)->SetViewTargetWithBlend(NextCameraActor, TransitionTime);
CurrentCameraActor = NextCameraActor;
//NextCameraActor = nullptr;

UGameplayStatics::GetPlayerController(GetWorld(), 0)->EnableInput(UGameplayStatics::GetPlayerController(GetWorld(), 0));

if(DefaultCameraActor == nullptr) DefaultCameraActor = CurrentCameraActor;

return;
Expand Down
38 changes: 36 additions & 2 deletions Source/unbread/Private/SCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "SPlayerState.h"
#include "SGameplayAbility.h"
#include "SHealthAttributeSet.h"
#include "Camera/CameraActor.h"
#include "Kismet/KismetMathLibrary.h"


// Sets default values
Expand Down Expand Up @@ -82,13 +84,35 @@ void ASCharacter::Move(const FInputActionValue& Value)
{
const FVector2D MoveVector = Value.Get<FVector2D>();
FVector2d NormalizedMoveVector = MoveVector.GetSafeNormal();

FVector Forward, Right;

// Get the camera transform
if(DynamicCamera->CurrentCameraActor)
{
//const auto Camera = Cast<ACameraActor>(DynamicCamera->CurrentCameraActor);
//Right = FVector(1.f, 0.f, 0.f);
//Forward = FVector(0.f, 1.f, 0.f);

const FRotator CameraWorldRotation = DynamicCamera->CurrentCameraActor->GetComponentByClass<UCameraComponent>()->GetRelativeRotation() + DynamicCamera->CurrentCameraActor->GetActorRotation();

//Forward = UKismetMathLibrary::GetForwardVector(CameraWorldRotation);
Right = UKismetMathLibrary::GetRightVector(CameraWorldRotation); //Forward.RotateAngleAxis(90.f, FVector(0.f, 0.f, 1.f));
Forward = Right.RotateAngleAxis(-90.f, FVector(0.f, 0.f, 1.f));
}

else
{
Forward = FVector(1.f, 0.f, 0.f);
Right = FVector(0.f, 1.f, 0.f);
}

// Forward / Backward
const FVector Forward = FVector(1.f, 0.f, 0.f);

AddMovementInput(Forward, NormalizedMoveVector.Y * Speed);


// Right / Left
const FVector Right = FVector(0.f, 1.f, 0.f);
AddMovementInput(Right, NormalizedMoveVector.X * Speed);

// TODO: Update forward and right vectors according to camera position and rotation
Expand Down Expand Up @@ -158,6 +182,11 @@ void ASCharacter::Jump(const FInputActionValue& Value)

void ASCharacter::Sprint()
{
if(bIsHeadForm)
{
return;
}

bIsWalking = !bIsWalking;
if (bIsWalking)
{
Expand All @@ -183,6 +212,11 @@ void ASCharacter::CheckAmmo()

void ASCharacter::ShootProjectile()
{
if(bIsHeadForm)
{
return;
}

FVector ProjectileSpawnLocation = GetMesh()->GetSocketLocation("ProjectileSpawn") + FVector(0.f, 0.f, 150.f);
FRotator ProjectileSpawnRotation = GetMesh()->GetRelativeRotation() + FRotator(0.0f, 90.f, -10.f);
FTransform SpawnTM = FTransform(ProjectileSpawnRotation, ProjectileSpawnLocation);
Expand Down
5 changes: 4 additions & 1 deletion Source/unbread/Public/CameraRegisterVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ void ACameraRegisterVolume::OnEnterVolume(UPrimitiveComponent* OverlappedComp, A
void ACameraRegisterVolume::OnExitVolume(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if(OtherActor->GetClass()->ImplementsInterface(UDynamicCameraInterface::StaticClass())) {
IDynamicCameraInterface::Execute_SetNextCamera(OtherActor, nullptr);
if(bResetCameraOnExit)
{
IDynamicCameraInterface::Execute_SetNextCamera(OtherActor, nullptr);
}
IDynamicCameraInterface::Execute_TransitionCamera(OtherActor, CameraTransitionTime);
}
}
3 changes: 3 additions & 0 deletions Source/unbread/Public/CameraRegisterVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class UNBREAD_API ACameraRegisterVolume : public AActor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
float CameraTransitionTime = 0.5f;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
bool bResetCameraOnExit = false;

protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
Expand Down
3 changes: 3 additions & 0 deletions Source/unbread/Public/SCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class UNBREAD_API ASCharacter : public ACharacter, public IDynamicCameraInterfac
bool bIsWalking;

void Sprint();

UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsHeadForm = false;

// TEMPORARY PROJECTILE ATTACK
UPROPERTY(EditAnywhere)
Expand Down

0 comments on commit ebdeb94

Please sign in to comment.