检查重叠时,虚幻编辑器会崩溃
Unreal Editor Crashes when checking for Overlap
虚幻的初学者在这里,我刚刚编写了以下代码,以便触发卷打开门(更改Actors偏航(。如果选定的演员(Actorthotopens(进入它,但是在扮演虚幻编辑器时,请Instatly崩溃。谁能帮忙?我希望它足够清楚我试图实现的目标,如果没有,请询问。
将此代码添加到.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:userslfdocumentsreposunrealcoursebuildinggamesourcebuildinggameopendoor.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/v4/t/lecture/4621210?start=15(
sai narayan可能是正确的,您可以在调用游戏逻辑代码之前检查指针有效性。
if ((PressurePlate != nullptr) && (ActorThatOpens != nullptr))
{
if (PressurePlate->IsOverlappingActor(ActorThatOpens))
{
OpenDoor();
}
}
如果您之前未设置PresurePlate
或ActorThatOpen
,则可以防止您的程序崩溃。
请记住,TickComponent
功能将在演员拥有您的组件的演员中始于游戏世界。因此,在您将组件成员初始初始初始化之前,可以调用TickComponent
。
这看起来像是空指针异常。您正在访问尚未正确初始化的指针。
" Actortartopens"在哪里初始化?还有"压力板",请进行双检查以确保这些是有效的指针。
如果重叠被调用/从空对象调用/可能导致崩溃。
不要为此使用tick,这是不必要的开销。UE4是事件驱动的,因此请实现OnoverLapbegin函数以调用您的特定代码。
编辑:首先在蓝图中进行,请确保您的逻辑和执行路径是正确的,然后将其移至代码。这正是蓝图的目的。
相关文章:
- 我无法在Visual Studio代码中使用CIN输入答案,它说输入您的年龄,但它说只读文本编辑器如何解决这个问题?
- 防止在C++中选择错误文件时提升 xml 解析器崩溃
- "未定义对'WinMain@16'的引用"gcc 编辑器中的错误
- 如何从C++而不是虚幻编辑器中添加静态网格体组件的值?
- UE4 - Visual Studio在我从编辑器添加新的c ++文件后无法打开任何源文件 - UBT_COMPILED
- Popen使Qt调试器崩溃
- Visual Studio 2017 ARM 交叉编译链接器崩溃
- 图标编辑器中的自定义颜色 (VS 2015)
- Qt的QFontMetrics::horizontalAdvance()缺少代码编辑器实现
- CPLEX MIP 优化器崩溃并显示0x9信号
- 如何在文本编辑器中处理 [-Wc++11-extensions]
- C++链接编辑器找不到函数声明(未定义的引用)
- 如何将按钮添加到节点的属性编辑器面板,该面板调用该节点内的方法?
- QT创建者(4.2.2)编辑器中的独特指针导航
- 带有cmake的qtCreator,编辑器中未正确解析__cplusplus值
- 检查重叠时,虚幻编辑器会崩溃
- 如何在Windows中将使用Qt制作的记事本设置为默认文本编辑器
- 尝试在自定义 QT 创建器文本编辑器中创建查找和替换循环.我似乎无法设置光标位置
- getowner()导致虚幻编辑器崩溃
- Qt Creator在使用其C++编辑器操作文件时崩溃