【UE4 C++】 获取Actor、Controller、Pawn、Character
获取 Actor
TActorIterator 遍历
可以用于遍历 Actor,也可以用于遍历 Component
for (TActorIterator<AStaticMeshActor> ActorIter(GetWorld()); ActorIter; ++ActorIter)
{
UKismetSystemLibrary::PrintString(GetWorld(), FString::Printf(TEXT("%s"), *ActorIter->GetName()));
}
UKismetSystemLibrary::GetAllActorsOfClass
Syntax
static void GetAllActorsOfClass(const UObject* WorldContextObject, TSubclassOf<AActor> ActorClass, TArray<AActor*>& OutActors);
代码实现
TArray<AActor*> OutActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), OutActors);
for (AActor* actor : OutActors)
{
UKismetSystemLibrary::PrintString(GetWorld(), actor->GetName());
}
UKismetSystemLibrary::GetAllActorsWithTag
Syntax
static void GetAllActorsWithTag(const UObject* WorldContextObject, FName Tag, TArray<AActor*>& OutActors);
UKismetSystemLibrary::GetAllActorsWithInterface
Syntax
static void GetAllActorsWithInterface(const UObject* WorldContextObject, TSubclassOf<UInterface> Interface, TArray<AActor*>& OutActors);
获取 Controller
可配合 Cast 转换成对应的 Controller
UKismetSystemLibrary::GetPlayerController
Syntax
static class APlayerController* GetPlayerController(const UObject* WorldContextObject, int32 PlayerIndex);
代码实现
APlayerController* playerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
UWorld::GetFirstPlayerController
代码实现
APlayerController* playerController = GetWorld()->GetFirstPlayerController();
获取 Pawn
UKismetSystemLibrary::GetPlayerPawn
代码实现
APawn* myPawn = Cast<ADrone>(UGameplayStatics::GetPlayerPawn(GetWorld(), 0));
GetPawn
代码实现
APawn* myPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
获取 Character
UGameplayStatics::GetPlayerCharacter
代码实现
ACharacter* myPawn = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
GetCharacter
代码实现
ACharacter* myPawn = GetWorld()->GetFirstPlayerController()->GetCharacter();
【UE4 C++】 获取Actor、Controller、Pawn、Character的更多相关文章
- 【转载】 [unreal4入门系列之七] UE4中的Actor类和Pawn类
原文地址: http://www.52vr.com/article-558-1.html 现在我们开始进入UE4的代码开发工作.首先,UE4的类框架是非常庞大的,看起来有点让人措手不及.不过正因为UE ...
- UE4 中在 Actor 中动态 Create Component 与ChildActor 的 小笔记
Note:旧版本的UE4 的Attach 和12.13版本有些不一样 创建Component: UCpp_MyComponent* temp_imageCom = NewObject<UCpp_ ...
- Yii里获取当前controller和action的id
Yii里获取当前controller和action的id 在控制器里$name = $this->getId(); // controller$name = $action->id; ...
- spring mvc DispatcherServlet详解之一--request通过HandlerMaping获取控制器Controller过程
整个spring mvc的架构如下图所示: 现在来讲解DispatcherServletDispatcherServlet的第一步:获取控制器. HandlerMapping HandlerMappi ...
- token获取在controller层中
集合判断是否为空 注意:token获取在controller层中,token中存的所有数据都要在controller中获取 在自己的接口里调用别的接口需要判断一下返回值是否为空
- Asp.Net MVC 获取当前 Controller Action Area
获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); 获取Action名称: ViewContext.Ro ...
- C# 通过反射获取MVC Controller里的类名,方法名,参数列表,返回值类型,Description描述,自定义Attribute
需要反射的DLL里的一个类: namespace ElegantWM.WebUI.Areas.Admin.Controllers { [Description("功能模块管理")] ...
- ios 自定义cell类中获取当前controller push
有时候在自定义cell的过程中,当cell中又button的时候,把button的点击时间写在cell中的时候,需要获取到cell的父视图控制器然后push,可以自建一个类,命名为: GetCurre ...
- MVC获取当前Controller/Action名称
1.视图中获取: var actionName=ViewContext.RouteData.Values["action"].ToString().ToLower(); var c ...
随机推荐
- 揭秘盒马鲜生 Android 短视频秒播优化方案
短视频作为内容重要的承载方式,是吸引用户的重点,短视频的内容与体验直接关系到用户是否愿意长时停留.因此,体验的优化就显得尤为重要.上一篇我们分享了 iOS 短视频秒播优化,这篇我们来聊聊 Androi ...
- Docker基本指令
镜像操作 检索:docker search 关键字 eg:docker search redis 拉取:docker pull 镜像名称:tag :tag可选的 tag表示标签,多为软件版本,默认是l ...
- 性能测试必备命令(4)- pstree
性能测试必备的 Linux 命令系列,可以看下面链接的文章哦 https://www.cnblogs.com/poloyy/category/1819490.html 介绍 显示进程树 语法格式 ps ...
- discuz连接微博登陆,第三方登录
首先记一下discuz的ucenter的架构: ucenter 是用户中心.其他的应用都是和ucenter连接,包括discuz也是ucenter的一个应用(默认的); 第一步: 在ucenter新建 ...
- php curl发送数据和文件
function mycurl($file, $url, $aid) { // 如果文件名是中文名,将中文字符编码转换一下 $file=iconv("UTF-8","gb ...
- css3 flex的IE8浏览器兼容问题
我这是进行判断浏览器 css判断ie版本才引用样式或css文件 <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> &l ...
- Linux系列(27) - 三剑客grep、awk、sed
Linux下一切皆文件,对Linux的操作就是对文件的处理 Linux中最重要的三个命令在业界被称为"三剑客",它们是awk,sed,grep 正则表达式就好比一个模版,这个模板就 ...
- Ajax与Gson
1. ajax的底层操作方法: 代码get请求 Get请求 2. Post请求 $("#chufa").click(function () { var val = $(" ...
- vue1.0,2.0区别 生命周期
1.生命周期 删除 beforeCompile compiled ready,新增beforeMounted mounted beforeUpdate updated 2.for循环里取消了$ind ...
- P3306-[SDOI2013]随机数生成器【BSGS】
正题 题目链接:https://www.luogu.com.cn/problem/P3306 题目大意 给出一个\(p,a,b,x_1,t\),有\(x_i=ax_{i-1}+b\) 求一个最小的\( ...