Update Character for Random Craving
This commit is contained in:
parent
243e4465ab
commit
ec609c72bf
BIN
SeagullGame/Content/Items/BPI_CubeTransparent.uasset
(Stored with Git LFS)
Normal file
BIN
SeagullGame/Content/Items/BPI_CubeTransparent.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
SeagullGame/Content/Items/M_CravingTransparent.uasset
(Stored with Git LFS)
Normal file
BIN
SeagullGame/Content/Items/M_CravingTransparent.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
SeagullGame/Content/TopDown/Blueprints/SKM_Quinn_Socket.uasset
(Stored with Git LFS)
BIN
SeagullGame/Content/TopDown/Blueprints/SKM_Quinn_Socket.uasset
(Stored with Git LFS)
Binary file not shown.
@ -136,6 +136,19 @@ void ASeagullGameCharacter::StartGame()
|
||||
GetWorld()->GetTimerManager().ClearTimer(GameTimerHandle);
|
||||
}
|
||||
GetWorld()->GetTimerManager().SetTimer(GameTimerHandle, this, &ASeagullGameCharacter::EndGame, GameTime, false);
|
||||
|
||||
FTimerHandle CravingTimerHandle;
|
||||
GetWorld()->GetTimerManager().SetTimer(CravingTimerHandle, [this]()
|
||||
{
|
||||
TSubclassOf<AItemActor> ItemActor = ItemActors[FMath::RandRange(0, ItemActors.Num() - 1)];
|
||||
if (IsValid(CravingItemActor)) CravingItemActor->Destroy();
|
||||
CravingItemActor = GetWorld()->SpawnActor(ItemActor);
|
||||
CurrentCraving = Cast<AItemActor>(CravingItemActor)->ItemType;
|
||||
CravingItemActor->SetActorEnableCollision(false);
|
||||
USkeletalMeshComponent* MeshComponent = GetMesh();
|
||||
if (!MeshComponent->HasAnySockets()) return;
|
||||
CravingItemActor->AttachToComponent(MeshComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, "CravingSocket");
|
||||
}, 30, true, 3);
|
||||
}
|
||||
|
||||
void ASeagullGameCharacter::EndGame()
|
||||
|
@ -100,6 +100,10 @@ public:
|
||||
UBoxComponent* PickupBox;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Item")
|
||||
EItemType CurrentCraving;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Item")
|
||||
TArray<TSubclassOf<AItemActor>> ItemActors;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Item")
|
||||
AActor* CravingItemActor;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "John")
|
||||
float JohnsCurrentHunger = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user