我目前正在使用虚幻引擎4.我到目前为止所有的初学者教程都在虚幻编辑器中完成大部分工作,并且只使用C++来扩展虚幻自动生成的所有内容.我想更深入地了解如何主要(或者如果可能)使用C++来编程Unreal.我目前的目标是,完全从代码中设置一个简单的场景.
谁有人建议好的资源?
编辑:所以在熟悉了虚幻引擎的一般概念之后,我意识到大部分游戏开发都是通过使用Blueprint进行可视化脚本编写完成的.有没有办法将脚本语言与虚幻架构连接起来,以替换或集成到Blueprint中?
我是UE的新手,并做了一些简单的入门教程,因此我并不完全知道可用来帮助我找到所需内容的正确术语。游戏开始,我的鼠标消失,我只能使用我设置的输入;所以我的问题是,即使我不需要鼠标输入即可移动(如使用WASD一样),如何保持鼠标解锁并可以在不锁定相机的情况下移动?
我正在尝试使用C++在虚幻引擎4中编码视频.我可以访问单独的框架.下面是读取viewport's显示像素并存储在缓冲区中的代码.
//Safely get render target resource.
FRenderTarget* RenderTarget = TextureRenderTarget->GameThread_GetRenderTargetResource();
FIntPoint Size = RenderTarget->GetSizeXY();
auto ImageBytes = Size.X* Size.Y * static_cast<int32>(sizeof(FColor));
TArray<uint8> RawData;
RawData.AddUninitialized(ImageBytes);
//Get image raw data.
if (!RenderTarget->ReadPixelsPtr((FColor*)RawData.GetData()))
{
RawData.Empty();
UE_LOG(ExportRenderTargetBPFLibrary, Error, TEXT("ExportRenderTargetAsImage: Failed to get raw data."));
return false;
}
Buffer::getInstance().add(RawData);
Run Code Online (Sandbox Code Playgroud)
虚幻引擎IImageWrapperModule可以从帧中获取图像,但注意到视频编码.我想要的是实时编码帧以用于直播服务.
我发现这篇文章使用FFMPEG将屏幕截图编码到一个视频中,这是我想要的,但我在为我的情况调整此解决方案时遇到了问题.代码已过时(例如,avcodec_encode_video更改为avcodec_encode_video2使用不同的参数).
贝娄是编码器的代码.
void Compressor::DoWork()
{
AVCodec* codec;
AVCodecContext* c = NULL;
//uint8_t* outbuf;
//int /*i, out_size,*/ outbuf_size;
UE_LOG(LogTemp, Warning, TEXT("encoding"));
codec = avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO); …Run Code Online (Sandbox Code Playgroud) 虚幻引擎4提供了三个说明符来控制暴露给Blueprint via的C++类成员的可见性和可编辑性UPROPERTY().
UE4源代码中的文档(另请参阅UE4 wiki,UE4文档)说明了关于可编辑性的以下内容:
VisibleAnywhere,VisibleInstanceOnly,VisibleDefaultsOnly:
...根本无法编辑.
EditAnywhere,EditInstanceOnly,EditDefaultsOnly:
......可以编辑......
用于BlueprintReadOnly:
...可以通过蓝图读取,但不能修改.
并且BlueprintReadWrite:
......可以从蓝图中读取或写入.
问题:
由于说明Visible*符已经将使用限制为仅在蓝图中读取,为什么它与BlueprintReadOnly?一起使用?第二个说明符不是多余的吗?例:
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
UMyActorComponent* MyActorComponent;
Run Code Online (Sandbox Code Playgroud)更令人困惑的是使用说明Edit*符,它允许在Blueprint中进行读写,同时BlueprintReadOnly限制在Blueprint中只读.两个指定者不是互相反对的吗?例:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
UMyActorComponent* MyActorComponent;
Run Code Online (Sandbox Code Playgroud)Visible*/ Edit*说明符是否在与说明符不同的上下文中有效BlueprintRead*?(问题不在于InstanceOnly(实例的属性窗口),DefaultsOnly(原型的属性窗口)和Anywhere(实例和原型))我最近使用了 UE4.19,并且能够正常运行我的项目。然后我尝试将项目升级到 UE4.20 并不断收到错误模块丢失,当我尝试构建它们时,它说从源代码重建。以下是我从 VS2017 错误列表中得到的错误。
无法编译该项目。您想在 Visual Studio 中打开它吗?运行 C:/Program Files/Epic Games/UE_4.20/Engine/Binaries/DotNET/UnrealBuildTool.exe Development Win64 -Project="C:/Users/HMD GROUP/Documents/Unreal Projects/VRtestNOcalibration 4.20/VRtestNOcalibration.uproject" - TargetType=Editor -Progress -NoHotReloadFromIDE 为 VRtestNOcalibrationEditor 创建 makefile(没有现有的 makefile)执行完整的 C++ 包含扫描(没有包含缓存文件)使用 Visual Studio 2017 14.15.26726 工具链 (C:\Program Files (x86)\Microsoft Visual Studio\2017) \Community\VC\Tools\MSVC\14.15.26726) 和 Windows 10.0.16299.0 SDK (C:\Program Files (x86)\Windows Kits\10)。C:\Users\HMD GROUP\Documents\Unreal Projects\VRtestNOcalibration 4.20\Plugins\UPupilLabsVR\Source\UPupilLabsVR\UPupilLabsVR.Build.cs:警告:引用目录' C:\Program Files\Epic Games\UE_4.20\Engine\Source\UPupilLabsVR\Public' 不存在。@progress push 5% Parsing headers for VRtestNOcalibrationEditor Running UnrealHeaderTool "C:\Users\HMD GROUP\Documents\Unreal Projects\VRtestNOcalibration 4.20\VRtestNOcalibration.uproject" "C:\Users\HMD GROUP\Documents\Unreal Projects\VRtestNOcalibration0\Intermedi22 \Build\Win64\VRtestNOcalibrationEditor\Development\VRtestNOcalibrationEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors …
我尝试通过以下行使用此 ProjectPointToNavigation :
bool navResult = GetWorld()->GetNavigationSystem()->ProjectPointToNavigation(HitResult.Location, NavLocation, TeleportFadeTimeExtent);
Run Code Online (Sandbox Code Playgroud)
但是,该方法ProjectPointToNavigation已被此函数弃用
我的问题是,如何重写上面的代码以使用最新的ProjectPointToNavigation功能?
我尝试了以下方法:
bool navResult = UNavigationSystemV1::ProjectPointToNavigation(HitResult.Location, NavLocation, TeleportFadeTimeExtent);
Run Code Online (Sandbox Code Playgroud)
上面的代码向我显示了以下错误:
“UNaviationSystemV1::ProjectPointToNavigation”对重载函数的不明确调用
抱歉,如果我的问题很简单,我是虚幻引擎的新手,仍在学习其开发(在我的第一阶段)
更新:
我尝试了以下方法(在header课堂上):
UPROPERTY()
class UNavigationSystemV1* NavSystem;
Run Code Online (Sandbox Code Playgroud)
在.cpp班上:
bool navResult = NavSystem->ProjectPointToNavigation(HitResult.Location, NavLocation, TeleportFadeTimeExtent);
Run Code Online (Sandbox Code Playgroud)
它仍然不起作用,我收到以下错误:
严重性代码说明项目文件行抑制状态错误 LNK2019 无法解析的外部符号“__declspec(dllimport) public: bool __cdecl UNavigationSystemV1::ProjectPointToNavigation(struct FVector const &,struct FNavLocation &,struct FVector const &,struct FNavAgentProperties const *,class TSharedPtr)” (__imp_?ProjectPointToNavigation@UNaviationSystemV1@@QEAA_NAEBUFVector@@AEAUFNavLocation@@0PEBUFNavAgentProperties@@V?$TSharedPtr@$$CBUFNavigationQueryFilter@@$00@@@Z) 在函数“private: void __cdecl AVRCharacter::UpdateDestinationMarker(void)”中引用 ( ?UpdateDestinationMarker@AVRCharacter@@AEAAXXZ) 资源管理器 E:\Unreal Projects\Explorer\Intermediate\ProjectFiles\VRCharacter.cpp.obj 1
任何指导将不胜感激
我知道代表相当于调度员。但事件声明的类型有很多种。使用 UFUNCTION 宏事件可以使用 BlueprintNativeEvents 和 BlueprintImplementableEvent 来定义。但还有 DECLARE_EVENT 宏。我喜欢把事情想得太多。有人可以解释调度程序、事件和各种类型事件之间的区别吗?在观察者模式中,调度程序是可观察的,事件是这些可观察的观察者吗?
当我尝试为虚幻引擎 4.26 构建 cpp 代码时出现错误。我正在尝试添加到我的游戏功能中,以确定我玩游戏时的表面类型。这就是我添加 UDeterminSurfaceType 函数的原因。部分代码如下所示:
SurfaceType = UPhysicalMaterial::DetermineSurfaceType(Hit.PhysMaterial.Get());
UParticleSystem* SelectedEffect = nullptr;
switch (SurfaceType)
{
case SurfaceType1:
SelectedEffect = FleshImpactEffect;
break;
case SurfaceType2:
SelectedEffect = FleshImpactEffect;
break;
default:
SelectedEffect = DefaultImpactEffect;
break;
}
if (SelectedEffect)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), SelectedEffect, Hit.ImpactPoint,
Hit.ImpactNormal.Rotation());
}
Run Code Online (Sandbox Code Playgroud)
我知道事实尚未完善,我稍后会这样做。添加此行并构建项目后,出现 LNK2019 错误。
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: static enum
EPhysicalSurface __cdecl UPhysicalMaterial::DetermineSurfaceType(class UPhysicalMaterial const *)"
(__imp_?DetermineSurfaceType@UPhysicalMaterial@@SA?AW4EPhysicalSurface@@PEBV1@@Z) referenced in
function "public: virtual void __cdecl ASWeapon::Fire(void)" (?Fire@ASWeapon@@UEAAXXZ)
Run Code Online (Sandbox Code Playgroud)
此错误意味着,我的 ASWeapon 类头文件中有一个名为“Fire”的方法,但它在您的 SWeapon.CPP 文件中不存在。因此,链接器为您的武器类创建了一个 OBJ 文件,然后当它尝试将声明与实现相匹配时,它找不到实现并且您会收到这个可爱的链接器错误。但是我已经在 CPP 和头文件中都有方法“Fire”。它是在这里创建的: …
我正在尝试将 Unreal 4.25.3 项目转换为 Unreal 4.27。我已经升级了所有插件(他们都说现在支持 4.27),并解决了一系列编译器错误,但我似乎无法克服我的一个类上的这一组特定的链接器错误。
我有一个名为的类,UStoreModeSettings我在其中创建一些新的项目设置配置变量。编译时的错误信息:
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "D:\dev\myVR-Unreal-4.27\Engine\Build\BatchFiles\Build.bat myVREditor Win64 DebugGame -Project="D:\dev\myVR-4.27\myVR\myVR.uproject" -WaitMutex -FromMsBuild" exited with code 6. myVR C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets 46
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: virtual __cdecl UDeveloperSettings::~UDeveloperSettings(void)" (__imp_??1UDeveloperSettings@@UEAA@XZ) referenced in function "public: virtual __cdecl UStoreModeSettings::~UStoreModeSettings(void)" (??1UStoreModeSettings@@UEAA@XZ) myVR D:\dev\myVR-4.27\myVR\Intermediate\ProjectFiles\StoreModeSettings.cpp.obj 1
Error LNK2019 unresolved external symbol "public: __cdecl UStoreModeSettings::UStoreModeSettings(class FObjectInitializer const &)" (??0UStoreModeSettings@@QEAA@AEBVFObjectInitializer@@@Z) referenced in function "public: void __cdecl …Run Code Online (Sandbox Code Playgroud) 我有一个蓝图函数库“TextManager”,它有一个test_function“Test”。
函数的声明是:
UFUNCTION(BlueprintCallable, Category = "Custom", meta = (Keywords = "testfunction"))
static void TestFunc(FString & InString, int & InInt);
Run Code Online (Sandbox Code Playgroud)
和定义:
void UTextFileManager::TestFunc(FString & InString, int & InInt)
{
InString = "Has changed";
}
Run Code Online (Sandbox Code Playgroud)
但是当我在 bp 中调用它时,两个输入就变成了输出。
谁能解释这是为什么吗?
任何帮助,将不胜感激!
如果您无法回答我的问题,请告诉我!