Update John to Have Cravings Displayed on Head

This commit is contained in:
Philip W 2024-01-28 10:22:18 +00:00
parent 19cc9057c2
commit 8e197d7c64
8 changed files with 30 additions and 5 deletions

BIN
SeagullGame/Content/John/BP_John.uasset (Stored with Git LFS)

Binary file not shown.

BIN
SeagullGame/Content/John/John_standing_geared_uo.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
SeagullGame/Content/John/Material/M_JohnGearedUp.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -15,6 +15,7 @@
#include "GameFramework/SpringArmComponent.h" #include "GameFramework/SpringArmComponent.h"
#include "Materials/Material.h" #include "Materials/Material.h"
#include "Engine/World.h" #include "Engine/World.h"
#include "Kismet/GameplayStatics.h"
ASeagullGameCharacter::ASeagullGameCharacter() ASeagullGameCharacter::ASeagullGameCharacter()
{ {
@ -92,7 +93,12 @@ void ASeagullGameCharacter::Tick(float DeltaSeconds)
void ASeagullGameCharacter::BeginPlay() void ASeagullGameCharacter::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
TArray<AActor*> Johns;
UGameplayStatics::GetAllActorsWithTag(GetWorld(), FName("John"), Johns);
if (Johns.Num() > 0)
{
John = Johns[0];
}
//Add Input Mapping Context //Add Input Mapping Context
if (APlayerController* PlayerController = Cast<APlayerController>(Controller)) if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
{ {
@ -145,10 +151,11 @@ void ASeagullGameCharacter::StartGame()
CravingItemActor = GetWorld()->SpawnActor(ItemActor); CravingItemActor = GetWorld()->SpawnActor(ItemActor);
CurrentCraving = Cast<AItemActor>(CravingItemActor)->ItemType; CurrentCraving = Cast<AItemActor>(CravingItemActor)->ItemType;
CravingItemActor->SetActorEnableCollision(false); CravingItemActor->SetActorEnableCollision(false);
USkeletalMeshComponent* MeshComponent = GetMesh(); if (!IsValid(John)) return;
UStaticMeshComponent* MeshComponent = Cast<UStaticMeshComponent>(John->GetComponentByClass(UStaticMeshComponent::StaticClass()));
if (!MeshComponent->HasAnySockets()) return; if (!MeshComponent->HasAnySockets()) return;
CravingItemActor->AttachToComponent(MeshComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, "CravingSocket"); CravingItemActor->AttachToComponent(MeshComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, "CravingSocket");
}, 30, true, 3); }, 60, true, 2);
} }
void ASeagullGameCharacter::EndGame() void ASeagullGameCharacter::EndGame()
@ -210,6 +217,7 @@ void ASeagullGameCharacter::DropItem()
CurrentItem->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform); CurrentItem->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
FVector DropLocation = MeshComponent->GetSocketLocation("ItemSocket"); FVector DropLocation = MeshComponent->GetSocketLocation("ItemSocket");
DropLocation += GetActorForwardVector() * 100; DropLocation += GetActorForwardVector() * 100;
DropLocation += GetActorUpVector() * 50;
GetWorld()->SpawnActor(Cast<AItemActor>(CurrentItem)->ItemNoPhysics, &DropLocation); GetWorld()->SpawnActor(Cast<AItemActor>(CurrentItem)->ItemNoPhysics, &DropLocation);
CurrentItem->Destroy(); CurrentItem->Destroy();
CurrentItem = nullptr; CurrentItem = nullptr;

View File

@ -123,6 +123,8 @@ public:
UPROPERTY(BlueprintReadOnly, Category = "Item") UPROPERTY(BlueprintReadOnly, Category = "Item")
AActor* CravingItemActor; AActor* CravingItemActor;
UPROPERTY(BlueprintReadOnly, Category = "John")
AActor* John;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "John") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "John")
float JohnsCurrentHunger = 0; float JohnsCurrentHunger = 0;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "John") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "John")