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



  • 相关阅读:
    阿里巴巴FastJSON使用实例
    JSON知识点
    java序列化和反序列化
    JAVA里的VO、BO、PO分别指什么?
    Oracle基础语句练习记录
    maven命令
    maven官方教程
    linux下开启、关闭、重启mysql服务
    linux常用命令记录
    动态网页项目无法启动
  • 原文地址:https://www.cnblogs.com/nafio/p/9137075.html
Copyright © 2011-2022 走看看