zoukankan      html  css  js  c++  java
  • UE4笔记-Component相关问题记录

    记录UE4,Component的应用的一些问题.

    Q. 在UE4中往Actor/Pawn 中动态创建 Component与ChildActor 

    Note:旧版本的UE4 的Attach 和12.13版本有些不一样

    创建Component:

    UCpp_MyComponent* temp_imageCom = NewObject<UCpp_MyComponent>(this, UCpp_MyComponent::StaticClass());
    temp_imageCom->RegisterComponent();
    temp_imageCom->AttachToComponent(pParentComponent, FAttachmentTransformRules::KeepRelativeTransform);

    创建Actor Component:

    仅多了一步SetChildActorClass

    auto temp_childActorComponent = NewObject<UChildActorComponent>(this, UChildActorComponent::StaticClass());
    temp_imageCom->RegisterComponent();
    temp_childActorComponent->SetChildActorClass(*MyActorClass);
    temp_imageCom->AttachToComponent(pParentComponent, FAttachmentTransformRules::KeepRelativeTransform);

    删除函数:(命名真是迷)

    DetachRootComponentFromParent

    例如:

     Note:慎用此UChildActorComponent的动态生成方式

       父类Actor 的SetActorEnableCollision 方法,是不会影响 UChildActorComponent 的 GetChildActor()的,但是最搞笑的是当你调用父类Actor 的 SetActorHiddenGame 却会隐藏掉 UChildActorComponent 的 GetChildActor()。

       如果想通过UChildActorComponent的GetChildActor()对Actor进行Transform 操作的话不能采用Relative, 必须采用World 或者直接Transform Actor 的 ActorComponent

  • 相关阅读:
    Python处理Excel文件
    WebSocket使用中Stomp Client连接报ERROR CODE 200的解决办法
    深入理解Java虚拟机——读书笔记
    主要排序算法的Java实现
    LeetCode 67 Add Binary
    LeetCode 206 单链表翻转
    POJ 2388
    POJ 1207 3N+1 Problem
    POJ 1008 Maya Calendar
    关于指针的一些基本常识
  • 原文地址:https://www.cnblogs.com/linqing/p/5979939.html
Copyright © 2011-2022 走看看