mcpField
U
unreal-engine

unreal-engine

github.com/alphaonedev开发49 次安装
代码仓库

关于 unreal-engine

unreal-engine 是使用 Unreal Engine、C++ 和 Blueprints 开发 3D 游戏与模拟项目的技能,涵盖渲染、物理、资产管理和跨平台构建。

主要功能

  1. 01使用 C++ 和 Blueprints 开发
  2. 02配置 3D 渲染与物理效果
  3. 03管理 Blueprint 和 C++ 资产
  4. 04使用异步任务
  5. 05通过 Unreal Build Tool 构建项目

适用场景

  1. 01用 Blueprints 快速验证游戏逻辑
  2. 02创建 C++ Actor 和玩法功能
  3. 03构建 3D 游戏与模拟项目
  4. 04排查构建和 Blueprint 错误

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/alphaonedev/openclaw-graph --skill unreal-engine

安装后在 Claude Code 中输入/unreal-engine确认已加载。

详细介绍

unreal-engine

用途

此技能可帮助 AI 进行 Unreal Engine 开发,重点是使用 C++ 和 Blueprints 为跨平台项目创建 3D 游戏和模拟。

适用场景

在进行高保真 3D 游戏开发时使用此技能,例如构建多人游戏、模拟或 VR 体验;项目需要高级渲染、物理效果或 AI 行为时;或需要将 C++ 与可视化脚本结合以快速制作原型时。

主要能力
  • 使用 C++ 和 Blueprints 进行跨平台构建:通过 Unreal Build Tool(UBT)支持 Windows、macOS、Linux 和游戏主机。
  • 3D 渲染和物理效果:使用 Niagara 实现视觉效果,或使用 PhysX 进行模拟,例如使用 UPrimitiveComponent::SetSimulatePhysics(true); 为对象启用物理效果。
  • 资源管理:处理蓝图(.uasset 文件)和 C++ 类,并使用 .ini 文件(如 Engine.ini)配置设置,例如 r.DefaultFeature.AutoExposure=True。
  • 多线程性能:通过 AsyncTask(ENamedThreads::GameThread, [](){ /* code */ }); 使用异步任务执行后台操作。
  • 与工具集成:使用 Git 进行版本控制,或通过 Blueprints 中的 HTTP 请求接入外部 API。
使用模式

要启动项目,请使用 UBT 创建新的 Unreal 项目,然后编写 C++ 代码或 Blueprints 来实现游戏逻辑。对于 C++ 模式,可扩展 UCLASS 对象并重写方法;对于 Blueprints,可创建连接到 Actor 的事件图表。始终使用 Editor 进行迭代测试:通过 UnrealEditor.exe MyProject.uproject 启动,然后使用 UnrealBuildTool.exe 编译更改。对于容易出错的任务,建议采用以下模式:在 UObject 操作中使用 try-catch 包装代码,并通过 UE_LOG(LogTemp, Warning, TEXT("Message")); 记录日志。

常用命令/API
  • UBT CLI 命令:使用 UnrealBuildTool.exe -project=Path/To/Project.uproject -target=MyGame -configuration=Development -platform=Win64 构建项目;使用 -clean 清理构建。
  • Editor 命令:从命令行运行 UnrealEditor.exe -game -log,以带日志的游戏模式启动。
  • C++ API 代码片段:使用 AActor* Actor = GetWorld()->SpawnActor<AActor>(AActor::StaticClass(), FVector(0,0,0), FRotator::ZeroRotator); 生成 Actor;使用 UStaticMeshComponent* MeshComp = Actor->FindComponentByClass<UStaticMeshComponent>(); 访问组件。
  • Blueprint API:在 Blueprints 中,使用 "Get Actor Location" 节点,然后接上 "Set Actor Location" 节点来移动对象;对应代码为:FVector NewLocation = Actor->GetActorLocation() + FVector(1,0,0); Actor->SetActorLocation(NewLocation);。
  • 配置格式:编辑 .ini 文件以调整设置,例如在 DefaultEngine.ini 中设置 [Core.System] AllowCommandLineAudioDeviceSelection=True;在代码中使用 GConfig->GetFloat(TEXT("Section.Key"), Value, GEngineIni); 加载配置。
集成说明

通过 Epic Games Launcher 安装 Unreal Engine,将其集成到工作流中(需要 Epic 账户;如果要编写自动化脚本并下载经过身份验证的内容,请使用环境变量 $EPIC_API_KEY)。对于外部工具,请在 Build.cs 文件中链接库,例如在 MyProject.Build.cs 中添加 PublicDependencyModuleNames.Add("Core");。与其他技能结合时,可与 "game-dev" 集群工具串联:将 C++ 编译器技能的输出传递给 UBT。使用环境变量设置路径,例如用 $UNREAL_ENGINE_PATH 表示根目录,并在脚本中设置为 export UNREAL_ENGINE_PATH=/path/to/engine。对于 API 集成,请使用 Unreal 的 HTTP 模块:TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest(); Request->OnRequestComplete().BindLambda([](FHttpRequestPtr Req, FHttpResponsePtr Res){ /* handle response */ }); Request->ProcessRequest();。

错误处理

常见错误包括因缺少依赖项导致的构建失败;使用 UnrealBuildTool.exe -verbose 检查日志,并通过在 Build.cs 中添加模块来修复,例如,如果缺少 "Core",则添加该模块并重新构建。对于运行时崩溃,可使用 ensure(Condition) 进行断言,或在异步代码中捕获异常:try { AsyncTask(ENamedThreads::AnyBackgroundThreadNormal, [](){ throw; }); } catch (...) { UE_LOG(LogTemp, Error, TEXT("Async error caught")); }。通过在编辑器中验证节点来处理蓝图编译错误;在代码中,使用 if (IsValid(Actor)) { /* proceed */ } else { UE_LOG(LogTemp, Warning, TEXT("Actor is invalid")); }。对于网络问题,可使用 if (Request->GetResponse()->GetResponseCode() == 200) { /* success */ } else { UE_LOG(LogTemp, Error, TEXT("HTTP error: %d"), Request->GetResponse()->GetResponseCode()); } 进行验证。

具体使用示例
  1. 构建一个简单的 C++ Actor:使用 UnrealBuildTool.exe -project=NewProject.uproject -newprojecttype=Game -game=Blank 创建新项目;然后在代码中,将 UFUNCTION() void MyFunction(); 添加到 MyActor.h,并将 void AMyActor::MyFunction() { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Function called")); } 添加到 MyActor.cpp;使用 UnrealBuildTool.exe Development Win64 NewProject 进行编译。
  2. 实现用于移动的蓝图:在 Unreal Editor 中,从 ACharacter 创建一个蓝图类;添加一个事件图表,将 "InputAction MoveForward" 连接到 "Add Movement Input";对应的 C++ 代码:在 AMyCharacter.cpp 中,void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); PlayerInputComponent->BindAxis("MoveForward", this, &AMyCharacter::MoveForward); } void AMyCharacter::MoveForward(float Value) { AddMovementInput(GetActorForwardVector(), Value); }。
图关系
  • 与集群相关:game-dev(例如,与 unity-engine 共享标签,适用于游戏开发工作流)。
  • 通过标签连接:unreal-engine 关联到 3D 渲染技能;game-development 与蓝图和专注于 C++ 的工具相关联。

评论

支持 Markdown