Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the level path more clear & Make the splitting mechanic more interesting #144

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Unbread/Art/Environment_Assets/Display_1.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Environment_Assets/SM_Sink.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Props/SM_Cake1.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Props/SM_Cake2.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Art/Props/SM_Cake_Rectangle2.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Core/AI/Melee/BP_MeleeAICharacter.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Core/AI/Ranged/BP_RangedAICharacter.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Core/Character/BP_ExplodingBody.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Maps/CoreLevelTest.umap
Git LFS file not shown
2 changes: 1 addition & 1 deletion Source/unbread/Private/AIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void AAIManager::NotifyAIState(EAIState state)
{
for(auto & Cntrl: Agents)
{
Cntrl->BBC->SetValueAsEnum("AIState", (uint8_t)state);
Cntrl->BBC->SetValueAsEnum("AIState", StaticCast<uint8>(state));
if(state == EAIState::Attack)
{
GetWorldTimerManager().ClearTimer(Cntrl->DetectionTimer);
Expand Down
33 changes: 30 additions & 3 deletions Source/unbread/Private/SCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,28 @@ void ASCharacter::Move(const FInputActionValue& Value)
// TODO: Update forward and right vectors according to camera position and rotation
//
//

if(!bUseNewRotation) return;

const FVector2D RotVector = Value.Get<FVector2D>();

const float Angle = FMath::Atan2(RotVector.Y, RotVector.X) * (180.0f / PI);

// Rotate the character relative to the current camera
FRotator CameraWorldRotation = DynamicCamera->CurrentCameraActor->GetComponentByClass<UCameraComponent>()->GetComponentRotation();
CameraWorldRotation.Roll = 0.f;
CameraWorldRotation.Pitch = 0.f;
const FRotator TargetRotation = UKismetMathLibrary::ComposeRotators(FRotator(0.0f, -1* Angle, 0.0f), CameraWorldRotation);

FRotator LerpedRotation = FMath::Lerp(GetMesh()->GetComponentRotation(), TargetRotation, LerpSpeed);

GetMesh()->SetWorldRotation(LerpedRotation);
}

void ASCharacter::Rotate(const FInputActionValue& Value)
{
if(bUseNewRotation) return;

const FVector2D RotVector = Value.Get<FVector2D>();

const float Angle = FMath::Atan2(RotVector.Y, RotVector.X) * (180.0f / PI);
Expand Down Expand Up @@ -222,7 +240,7 @@ void ASCharacter::LaunchHead()
bIsHeadForm = true;

// Store the current location and rotation of the character
const FVector BodySpawnLocation = GetMesh()->GetComponentLocation();
const FVector BodySpawnLocation = GetMesh()->GetComponentLocation() + FVector(0.f, 0.f, 50.f);
const FRotator BodySpawnRotation = GetMesh()->GetComponentRotation();

// Swap the mesh and launch the head
Expand All @@ -239,7 +257,11 @@ void ASCharacter::LaunchHead()
GetCharacterMovement()->Velocity = LaunchVelocity;

// Spawn the body and add it to ActiveBodies
ActiveBodies.AddUnique(GetWorld()->SpawnActor<ASExplodingBody>(BodyClass, BodySpawnLocation, BodySpawnRotation));
FActorSpawnParameters Parameters {};
Parameters.bNoFail = true;
auto Spawned = GetWorld()->SpawnActor<ASExplodingBody>(BodyClass, BodySpawnLocation, BodySpawnRotation, Parameters);
Spawned->Mesh->AddImpulse(-GetMesh()->GetRightVector() * 10 * HeadLaunchVelocityMultiplier);
ActiveBodies.AddUnique(Spawned);

}

Expand Down Expand Up @@ -268,7 +290,12 @@ void ASCharacter::ReformBody()
return;
}

NearestCrumbles->Destroy();
//NearestCrumbles->Destroy();

if(NearestCrumbles->GetClass()->ImplementsInterface(UInteractInterface::StaticClass()))
{
IInteractInterface::Execute_CrumbleInteraction(NearestCrumbles, this);
}
NearestCrumbles = nullptr;
bIsHeadForm = false;
Speed = WalkSpeed;
Expand Down
5 changes: 4 additions & 1 deletion Source/unbread/Private/SCrumbles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void ASCrumbles::Tick(float DeltaTime)
void ASCrumbles::CrumbleInteraction_Implementation(AActor* InstigatingActor)
{
IInteractInterface::CrumbleInteraction_Implementation(InstigatingActor);
Destroy();
if(bDestroyOnUse)
{
Destroy();
}
}

29 changes: 16 additions & 13 deletions Source/unbread/Private/SExplodingBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ ASExplodingBody::ASExplodingBody()
Root = CreateDefaultSubobject<USceneComponent>("RootComponent");
SetRootComponent(Root);

//Capsule = CreateDefaultSubobject<UCapsuleComponent>("CapsuleComponent");
//Capsule->SetupAttachment(Root);
//Capsule->SetRelativeLocation(FVector(0.f, 0.f, 88.f));
//Capsule->SetCapsuleHalfHeight(88.f);
//Capsule->SetCapsuleRadius(34.f);

Mesh = CreateDefaultSubobject<USkeletalMeshComponent>("SkeletalMesh");
Mesh->SetupAttachment(Root);
Mesh->SetRelativeScale3D(FVector(0.465f, 0.465f, 0.465f));
Mesh->SetRelativeLocation(FVector(0.f, 0.f, 0.f));

RadialForce = CreateDefaultSubobject<URadialForceComponent>("RadialForceComponent");
RadialForce->SetupAttachment(Root);
RadialForce->SetupAttachment(Mesh);
RadialForce->Radius = 200.f;
RadialForce->ImpulseStrength = 1000.f;
RadialForce->bImpulseVelChange = true;

Capsule = CreateDefaultSubobject<UCapsuleComponent>("CapsuleComponent");
Capsule->SetupAttachment(Root);
Capsule->SetRelativeLocation(FVector(0.f, 0.f, 88.f));
Capsule->SetCapsuleHalfHeight(88.f);
Capsule->SetCapsuleRadius(34.f);

Mesh = CreateDefaultSubobject<USkeletalMeshComponent>("SkeletalMesh");
Mesh->SetupAttachment(Capsule);
Mesh->SetRelativeScale3D(FVector(0.465f, 0.465f, 0.465f));
Mesh->SetRelativeLocation(FVector(0.f, 0.f, -90.f));

}

// Called when the game starts or when spawned
Expand All @@ -59,7 +59,10 @@ void ASExplodingBody::Explode()
{
RadialForce->FireImpulse();
const FActorSpawnParameters SpawnParameters;
GetWorld()->SpawnActor<ASCrumbles>(CrumblesActor, Mesh->GetComponentLocation(), Mesh->GetComponentRotation(), SpawnParameters);
FRotator SpawnRotation = Mesh->GetComponentRotation();
SpawnRotation.Pitch = 0.f;
SpawnRotation.Roll = 0.f;
GetWorld()->SpawnActor<ASCrumbles>(CrumblesActor, Mesh->GetComponentLocation(), SpawnRotation, SpawnParameters);
Destroy();
}

2 changes: 1 addition & 1 deletion Source/unbread/Private/SRespawnGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void ASRespawnGameMode::SpawnPlayer()

void ASRespawnGameMode::RespawnPlayer(AActor* Destroyed)
{
CurLives--;
//CurLives--;

if (CheckLoss()) return;

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 @@ -131,6 +131,9 @@ class UNBREAD_API ASCharacter : public ACharacter, public IDynamicCameraInterfac
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
float LerpSpeed = 0.6f;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
bool bUseNewRotation = true;

// Splitting Variables

UPROPERTY(EditAnywhere, BlueprintReadWrite)
Expand Down
3 changes: 3 additions & 0 deletions Source/unbread/Public/SCrumbles.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class UNBREAD_API ASCrumbles : public AActor, public IInteractInterface
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
UBoxComponent* TriggerVolume;

UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyOnUse = true;

protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
Expand Down
4 changes: 2 additions & 2 deletions Source/unbread/Public/SExplodingBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class UNBREAD_API ASExplodingBody : public APawn
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
URadialForceComponent* RadialForce;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
UCapsuleComponent* Capsule;
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
//UCapsuleComponent* Capsule;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
USkeletalMeshComponent* Mesh;
Expand Down
Loading