Hi and Thank you for responding. I am in need of help due to that my code wont respawn my Character after entering a KillZVolum. However i have made a class for the RespawnCharacter.
void AHumanDefender::HandleDeath(const class UDamageType& dmgType)
{
UGameplayStatics::OpenLevel(GetWorld(), TEXT(“?Restart”));
GetCharacterMovement()->Velocity *= 0;
SetActorLocation(CheckPointLocation);
}
UFUNCTION()
void SetCheckpointLocation() { CheckPointLocation = GetActorLocation(); };
The code in my RespawnPlayer class for Cpp is here
// Sets default values
ARespawnPlayer::ARespawnPlayer()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
BoxTrigger = CreateDefaultSubobject(TEXT(“BoxCollision”));
BoxTrigger->OnComponentBeginOverlap.AddDynamic(this, &ARespawnPlayer::BeginOverlap);
}
// Called when the game starts or when spawned
void ARespawnPlayer::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ARespawnPlayer::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ARespawnPlayer::BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
{
UE_LOG(LogTemp, Error, TEXT(“hit”));
AHumanDefender* Player = Cast(OtherActor);
if (Player != nullptr)
{
Player->SetCheckpointLocation();
}
}
and for H is here
UCLASS()
class ARespawnPlayer : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor’s properties
ARespawnPlayer();
UPROPERTY(EditDefaultsOnly)
class UBoxComponent* BoxTrigger;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION()
void BeginOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult &SweepResult);
};
I am pretty sure i wrote something wrong but i have no clue and i cant find any answers. Please help me and Thank you in beforhand