Hi guys, I’m trying to create a teleport system between two different rooms which are defined by AROOM class. The problem is when the character goes on the teleport field(which is a box component), unreal closes itself without warnings or errors and I have to reopen the IDE. Code is written below
ARoom.cpp
ARoom::ARoom()
{
....]
PassaggioTop->bGenerateOverlapEvents = true;
PassaggioTop->OnComponentBeginOverlap.AddDynamic(this, &ARoom::PassaggioTopStart);
....]
}
void ARoom::PassaggioTopStart(class UPrimitiveComponent* newComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
APupetto* PersonagGiocante = Cast<APupetto>(OtherActor);
if (PersonagGiocante != NULL) {
FVector Destinazione = (RoomTop->PassaggioBottom->GetComponentLocation()) + FVector::FVector(0.0f, -100.0f, 0.0f);
FRotator Rotazione = PersonagGiocante->GetActorRotation();
PersonagGiocante->TeleportTo(Destinazione, Rotazione, false, false);
//PersonagGiocante->SetActorLocation(Destinazione, false);
//PersonagGiocante->SetActorRotation(Rotazione);
this->Attiva = false;
RoomTop->Attiva = true;
RoomTop->AttivaCamera();
}
}
ARoom.h
UFUNCTION(BlueprintCallable, Category = Teletrasporto)
void PassaggioTopStart(class UPrimitiveComponent* newComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);