虛幻初學者在這裏,我只寫了下面的代碼以讓觸發器卷打開一扇門(變化角色偏航)。如果一個選定的Actor(ActorThatOpens)輸入它但是當玩虛幻編輯器時會不停地崩潰。誰能幫忙?我希望它足夠清楚我試圖達成的目標,如果不是,請問。虛幻編輯器在檢查重疊時崩潰
將此代碼添加到.H:
private:
UPROPERTY(VisibleAnywhere)
float OpenAngle = 90.0f;
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate;
UPROPERTY(EditAnywhere)
AActor* ActorThatOpens; //Pawn inherits from actor
,這給在.cpp:
void UOpenDoor::OpenDoor()
{
AActor* Owner = GetOwner();
FRotator NewRotation = FRotator(0.0f, -160.0f, 0.0f);
Owner->SetActorRotation(NewRotation);
}
// Called every frame
(line 42) void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
if (PressurePlate->IsOverlappingActor(ActorThatOpens))
{
OpenDoor();
}
}
我沒有設置壓盤的TriggerVolume,並將此作爲組分演員(門)。 我得到這個錯誤(UE編輯器崩潰):
Fatal error!
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000340
UE4Editor-Engine.dll!0x00000000AB8790A1
UE4Editor-BuildingGame-9929.dll!UOpenDoor::TickComponent() [d:\users\lf\documents\repos\unrealcourse\buildinggame\source\buildinggame\opendoor.cpp:42]
UE4Editor-Engine.dll!0x00000000ABC2C05F
UE4Editor-Engine.dll!0x00000000ABC51A15
UE4Editor-Engine.dll!0x00000000AC7DD9DD
UE4Editor-Engine.dll!0x00000000AC7E385D
UE4Editor-Core.dll!0x00000000C09ED84D
UE4Editor-Core.dll!0x00000000C09EDC6D
UE4Editor-Core.dll!0x00000000C0A0CCEB
UE4Editor-Engine.dll!0x00000000AC808861
UE4Editor-Engine.dll!0x00000000AC819532
UE4Editor-Engine.dll!0x00000000AC147B64
UE4Editor-Engine.dll!0x00000000AC1501AD
UE4Editor-Engine.dll!0x00000000ABF05B17
UE4Editor.exe!0x000000007A96DEE3
UE4Editor.exe!0x000000007A95EB40
UE4Editor.exe!0x000000007A95EBBA
UE4Editor.exe!0x000000007A970A29
UE4Editor.exe!0x000000007A9722B6
KERNEL32.DLL!0x00000000E8692774
ntdll.dll!0x00000000E8F90D61
ntdll.dll!0x00000000E8F90D61
(跟着這個教程:https://www.udemy.com/unrealcourse/learn/v4/t/lecture/4621210?start=15)
另外,如果你期望遊戲對象可以被銷燬,你應該做IsValidLowLevel()檢查。 –