【问题标题】:How do you get the world location of a UChildActorComponent?如何获得 UChildActorComponent 的世界位置?
【发布时间】:2019-02-16 12:24:42
【问题描述】:

我正在尝试在 UE4 中为我的 ACharacter 创建武器。该武器是一个 UChildActorComponent,其子类为 AWeapon。我目前遇到的问题是,当我想开火时,我无法获得起始位置。

tl;dr - 如何获取 UChildActorComponent 的世界位置?我尝试过的一切都返回 x,y,z(0,0,0)。

【问题讨论】:

  • 我猜 ChildActorComponent 有一个相对于角色的局部变换,但您仍然应该能够使用 ChildActorComponent::GetRootComponent()->GetComponentTransform() 来获取武器的 RootComponent 的世界变换。

标签: unreal-engine4


【解决方案1】:

也许你忘了调用:

MyChildActorComponent->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);

【讨论】:

    猜你喜欢
    • 2011-06-21
    • 2020-09-12
    • 2016-06-16
    • 1970-01-01
    • 2013-02-12
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多