您的位置:首页 > 产品设计 > UI/UE

ue4 常见问题解答

2016-03-18 20:55 926 查看
1.如何让客户端自动连接服务器

MyGame.exe 127.0.0.1

通过命令行参数指定服务器IP,就会自动进入游戏

参考:https://docs.unrealengine.com/latest/CHN/Programming/Basics/CommandLineArguments/index.html

2.如何以spectator模式启动客户端

在ULocalPlayer的派生类中重写GetGameLoginOptions函数,具体如下

FString UShooterLocalPlayer::GetGameLoginOptions() const

{

return TEXT("SpectatorOnly=1");

}

3.如何解决ue4 vs 调试不能看到FString等变量值的问题


调试

Visual Studio支持通过‘可视化查看器’来扩展调试器,从而轻松地查看常见的虚幻数据类型, 比如对象FNames 和动态数组。根据您所使用的Visual Studio 2010或Visual Studio 2012的不同, 这个功能的设置也有所区别。


针对Visual Studio 2012的可视化查看器设置

您会发现您的安装文件中包含了具备该可视化查看器逻辑的文件:
[ROCKETINSTALL]/Engine/Extras/VisualStudioDebugging/UE4.natvis


复制该文件到以下位置:
[VSINSTALLDIR]/Common7/Packages/Debugger/Visualizers/UE4.natvis
[USERPROFILE]/My Documents/Visual Studio 2012/Visualizers/UE4.natvis


参考:https://docs.unrealengine.com/latest/CHN/Programming/Development/VisualStudioSetup/index.html

4.ShooterGame 中LOS是什么意思

应该是 Line-of-sight 的意思

5.C++如何在屏幕上打印输出

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, NewControlRotation.ToString());

6.shootergame中projectile是如何检测碰撞的

在ProjectileMovementComponent.cpp中MoveUpdatedComponent函数调用

7.ue4中打包出来地图可以运行,从源码编译选择Development确不能运行,提示加载地图失败,怎么解决

在编辑器中烘培一下该地图,再进就可以(File->Cook Content For Windows)

8.在游戏中,给pawn加了一个发射子弹时的动作,但发现有时播放,有时不播放,后来发现是因为子弹个数问题,之前的逻辑子弹为0时播放会重新装弹,所以没有播放发射子弹的动作

9.函数前加 UFUNCTION(exec) 是什么意思

加了这个指明该函数可以在控制台执行

10.如何决定一个Actor是否需要同步

代码在ActorReplication.cpp中,IsNetRelevantFor函数

具体代码如下:

bool AActor::IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation) const
{
if (bAlwaysRelevant || IsOwnedBy(ViewTarget) || IsOwnedBy(RealViewer) || this == ViewTarget || ViewTarget == Instigator)
{
return true;
}
else if ( bNetUseOwnerRelevancy && Owner)
{
return Owner->IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation);
}
else if ( bOnlyRelevantToOwner )
{
return false;
}
else if ( RootComponent && RootComponent->AttachParent && RootComponent->AttachParent->GetOwner() && (Cast<USkeletalMeshComponent>(RootComponent->AttachParent) || (RootComponent->AttachParent->GetOwner() == Owner)) )
{
return RootComponent->AttachParent->GetOwner()->IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation);
}
else if( bHidden && (!RootComponent || !RootComponent->IsCollisionEnabled()) )
{
return false;
}

if (!RootComponent)
{
UE_LOG(LogNet, Warning, TEXT("Actor %s / %s has no root component in AActor::IsNetRelevantFor. (Make bAlwaysRelevant=true?)"), *GetClass()->GetName(), *GetName() );
return false;
}
if (GetDefault<AGameNetworkManager>()->bUseDistanceBasedRelevancy)
{
return ((SrcLocation - GetActorLocation()).SizeSquared() < NetCullDistanceSquared);
}

return true;
}
参考文档:https://wiki.beyondunreal.com/Everything_you_ever_wanted_to_know_about_replication_(but_were_afraid_to_ask)

11.FString转int32

Color = FCString::Atoi(*ColorStr)

ColorStr类型为FString,Color类型为int32

12.int32转FString

FString::FromInt(Color)

13.UnrealTournament编译报错

编译UnrealTournament Master,报错,后来查是因为本身代码有问题,然后下载了release版,链接报错 error LNK1181 Box2D.lib

解决方法,找到UnrealTournamentEditor.Target.cs文件,UEBuildConfiguration.bCompileBox2D 由false改为true,再编译,就正常了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: