I have a strange issue that causes the editor to crash when ‘walking into the light’. Heh.
When OpenDoor() or CloseDoor() is called without ‘AActor* Owner = GetOwner();’ the editor will freeze for a moment, then crash. I have created the Owner variable in the header file, and all code has been edited to mirror that in the video (including adding the GetOwner line to BeginPlay()).
This is not a show-stopper, as I can just leave the snippet in the door functions, but I’d like to solve the issue. I’m sure i’m overlooking something small, but cant find it. Any help would be appreciated.
Working Code:
// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
}
void UOpenDoor::OpenDoor()
{
AActor* Owner = GetOwner();
Owner->SetActorRotation(FRotator(0.0f, OpenAngle, 0.0f));
}
Code that Crashes:
// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
AActor* Owner = GetOwner();
ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
}
void UOpenDoor::OpenDoor()
{
Owner->SetActorRotation(FRotator(0.0f, OpenAngle, 0.0f));
}