1 设置编辑器中游戏播放的分辨率大小
播放-->高级设置
2 将射线通道转成射线类型,这个有空再看下
const ETraceTypeQuery TraceChannel = UEngineTypes::ConvertToTraceType(ECC_GameTraceChannel4);
3 摘自:https://blog.csdn.net/qq_35760525/article/details/77429242
4 关于ListenServer和DedicatedServer的区别可以看https://www.cnblogs.com/timy/p/9873587.html
5 GamePlay框架
6
UObject* const CusLink = PathFollowingComp->GetCurrentCusLinkOb();
7
在PossessedBy时保存委托,在Unpossessed的时候也记得释放掉
void CharacterBase::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
// Try setting the inventory source, this will fail for AI
InventorySource = NewController;
if (InventorySource)
{
InventoryUpdateHandle = InventorySource->GetSlottedItemChangedDelegate().AddUObject(this, &ARPGCharacterBase::OnItemSlotChanged); //保存FDelegateHandle
InventoryLoadedHandle = InventorySource->GetInventoryLoadedDelegate().AddUObject(this, &ARPGCharacterBase::RefreshSlottedGameplayAbilities);
}
// Initialize our abilities
if (AbilitySystemComponent)
{
AbilitySystemComponent->InitAbilityActorInfo(this, this);
AddStartupGameplayAbilities();
}
}
void CharacterBase::UnPossessed()
{
if (InventorySource && InventoryUpdateHandle.IsValid())
{
InventorySource->GetSlottedItemChangedDelegate().Remove(InventoryUpdateHandle);//释放FDelegateHandle
InventoryUpdateHandle.Reset();
InventorySource->GetInventoryLoadedDelegate().Remove(InventoryLoadedHandle);
InventoryLoadedHandle.Reset();
}
InventorySource = nullptr;
}
8
UE4禁用所有运行中的屏幕提示
摘自https://blog.csdn.net/qq_36409711/article/details/88693500
9
如果不想用复杂定时器,用简单延时吧
int NowTime = FPlatformTime::Seconds();
if (!(FPlatformTime::Seconds() - LastTime) > CoolDownTime) {return;}
GEngine->AddOnScreenDebugMessage(-1, 20.0F, FColor::Red, TEXT("HelloWorld"));
LastTime = FPlatformTime::Seconds();
10 关闭HotReload
关闭的方式是在Hello.Build.cs里加上一行:Definitions.Add("WITH_HOT_RELOAD_CTORS=0");
11
控制台
stat SceneRendering
会显示draw call,mesh的drawcall,light 的draw call,三角面等信息
控制台
r.ScreenPercentage 50 只会渲染一半解析度,四分之一的三角面
控制台
stat SceneRendering
控制台
stat GPU
控制台
stat game
5
6 AI在移动的时候有时候会出现抽搐的bug,原因是Nav导航把Runtime Generation从Dynamic改成Dynamic Modifiers Only
7 StaticMesh VS Instance
可见,对于同时渲染多mesh的场景中,用instance这种轻量级更加优化
可以使用
给这个组件设置StaticMesh,同时能拿到该变量
通过add instance来添加实例
对于大量mesh在场景中的优化:
1 可以将多个mesh转成一个大的mesh
2 大量mesh的碰撞对cpu将会是麻烦的,将HierarchicalInstancedStaticMesh禁用碰撞检测
禁用投射阴影
对于大量mesh在场景中时,根据距离相机的距离不同显示不同lod,在StaticMesh中设置不同LOD属性和距离
在游戏中,选择该选项,可以看到场景中的StaticMesh根据不同距离相机的位置显示不同LOD的变换效果
当然,对于分析性能优化等相关数据可以在这里去选择查看,和输入控制台一样的