Compare commits

...

3 Commits

Author SHA1 Message Date
baz 9436d16875 Set timeline start point OnOverlap 2024-11-25 02:38:50 +00:00
baz 3642b9418b Make SphereComponent a UPROPERTY 2024-11-25 02:36:39 +00:00
baz 3e14d6f6e3 Simplify moving to player character 2024-11-25 02:13:47 +00:00
4 changed files with 19 additions and 5 deletions

View File

@ -78,6 +78,14 @@ void APickup::OnOuterBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAct
{
PickupLocation = GetActorLocation();
PlayTimeLine();
double dist = FVector::Distance(GetActorLocation(), PlayerCharacter->GetActorLocation());
if (dist < OuterSphereComponent->GetScaledSphereRadius())
{
double ratio = FMath::Abs((dist / OuterSphereComponent->GetScaledSphereRadius()) - 1.0f);
TimelineComponent->SetNewTime(ratio);
}
}
}

View File

@ -36,11 +36,9 @@ void AVampireAIController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (AVampireCharacter* Player = Cast<AVampireCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)))
if (PlayerCharacter)
{
Blackboard->SetValueAsObject("Player", Player);
auto location = Player->GetActorLocation();
Blackboard->SetValueAsVector("PlayerLocation", location);
Blackboard->SetValueAsVector("PlayerLocation", PlayerCharacter->GetActorLocation());
}
}
@ -54,11 +52,18 @@ void AVampireAIController::OnPossess(APawn* InPawn)
EnemyCharacter->GetHealthComponent()->OnDamaged.AddDynamic(this, &AVampireAIController::OnDamaged);
EnemyCharacter->GetHealthComponent()->OnDeath.AddDynamic(this, &AVampireAIController::OnDeath);
PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
if (UBehaviorTree* bt = EnemyCharacter->GetBehaviorTree())
{
Blackboard->InitializeBlackboard(*bt->BlackboardAsset);
BehaviorTree->StartTree(*bt);
Blackboard->SetValueAsObject("SelfActor", EnemyCharacter);
if (PlayerCharacter)
{
Blackboard->SetValueAsObject("Player", PlayerCharacter);
}
}
}

View File

@ -22,7 +22,7 @@ class VAMPIRES_API AVampireAIController : public AAIController
UBehaviorTreeComponent* BehaviorTree;
APlayerCharacter* PlayerCharacter;
ACharacter* PlayerCharacter;
AEnemyCharacter* EnemyCharacter;

View File

@ -27,6 +27,7 @@ class VAMPIRES_API AGarlicWeapon : public AWeapon
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USphereComponent* SphereComponent;
TArray<FOverlappedEnemy> OverlappedEnemies;