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,想要获取输入的方法



  • 相关阅读:
    JS设计模式之----单例模式
    回流(reflow)与重绘(repaint)
    React native 图标使用
    JS常用几种存储方式的使用规则与各自特征
    Vue
    Promise 一自我总结
    三栏布局 && 两栏布局
    linux限制用户目录
    wireshark 抓包过滤
    python之tomcat自动化备份,更新
  • 原文地址:https://www.cnblogs.com/nafio/p/9137075.html
Copyright © 2011-2022 走看看