zoukankan      html  css  js  c++  java
  • ue4 杂记

    c++获取GameMode

     if(GetWorld()) {
       auto gamemode = (ASomeGameMode*)GetWorld()->GetAuthGameMode();
     }

    或者
    ASomeGameMode* gm = (ASomeGameMode*)GetWorld()->GetAuthGameMode();

    获取所有actors

    https://answers.unrealengine.com/questions/289453/get-all-actors-of-class-in-c.html


    获取controller

    UGameplayStatics::GetPlayerController(GetWorld(), 0);
    或者
    GetWorld()->GetFirstPlayerController()



    切换level

     void ACodeLevelChangeCharacter::SwapLevel()
     {
         UWorld* TheWorld = GetWorld();
     
         FString CurrentLevel = TheWorld->GetMapName();
         
         if (CurrentLevel == "ThirdPersonExampleMap")
         {
             UGameplayStatics::OpenLevel(GetWorld(), "Level2");
         }
         else
         {
             UGameplayStatics::OpenLevel(GetWorld(), "ThirdPersonExampleMap");
         }
     }

    查找object,actor

    for ( TObjectIterator<USkeletalMeshComponent> Itr; Itr; ++Itr )
    {
    	// Access the subclass instance with the * or -> operators.
    	USkeletalMeshComponent *Component = *Itr;
    	ClientMessage(Itr->GetName());
    }
    for (TActorIterator<AStaticMeshActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
    {
    	// Same as with the Object Iterator, access the subclass instance with the * or -> operators.
    	AStaticMeshActor *Mesh = *ActorItr;
    	ClientMessage(ActorItr->GetName());
    	ClientMessage(ActorItr->GetActorLocation().ToString());
    }


    Unreal中的构造函数,只在生成到场景中的时候执行,启动游戏是不会执行构造函数的


    对于不是主Controller绑定的actor,想要获取输入的方法



  • 相关阅读:
    php 3des加密 兼容JAVA 多么痛的领悟呀
    主机序和网络序
    不用递归实现无限分类数据的树形格式化
    python学习笔记之open函数的用法
    据说是百度面试题(1)
    YII+DWZ三级城市联动挂件
    wpf 报错: 在 AddNew 或 EditItem 事务过程中不允许“DeferRefresh”。
    MVVM了解
    纪念2015年上半年
    c# 委托与事件
  • 原文地址:https://www.cnblogs.com/nafio/p/9137075.html
Copyright © 2011-2022 走看看