首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >虚幻引擎5组世界旋转

虚幻引擎5组世界旋转
EN

Stack Overflow用户
提问于 2022-08-19 18:00:05
回答 1查看 222关注 0票数 0

我目前正在尝试复制一个非常简单的教程,用于在不真实的引擎5中建立一个2D平台。我想在c++中复制蓝图方式。然而,我不能设置一个弹簧部件的绝对旋转与一个附加的相机。从cpp代码中,我创建了一个蓝图,并成功地编译了一切。然而,改变旋转并不会。

我的代码是什么样子的:

代码语言:javascript
运行
复制
#include "Hero_Paper_Character.h"

#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

AHero_Paper_Character::AHero_Paper_Character() {
    SpringArmComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
    SpringArmComponent->SetupAttachment(RootComponent);
    SpringArmComponent->SetWorldRotation(FRotator(0.0f, -90.0f, 0.0f));
    SpringArmComponent->TargetArmLength = 550.f;
    SpringArmComponent->bEnableCameraLag = true;
    SpringArmComponent->CameraLagSpeed = 4.f;

    CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
    CameraComponent->SetupAttachment(SpringArmComponent);

}

不幸的是,我也尝试过设置不同的东西,但没有成功:

代码语言:javascript
运行
复制
    SpringArmComponent->SetUsingAbsoluteRotation(true);
    SpringArmComponent->AddWorldRotation(FRotator(0.0f, -90.0f, 0.0f));

这不会改变任何事情,也不会发生任何事情。有两天我似乎找不到原因。另外,改变目标目标长度也是有效的。任何暗示都是非常感谢的。

下面是相应的标题:

代码语言:javascript
运行
复制
#include "CoreMinimal.h"

#include "PaperCharacter.h"

#include "Hero_Paper_Character.generated.h"

UCLASS()
class PLATFORMER_2D_API AHero_Paper_Character : public APaperCharacter
{
    GENERATED_BODY()
    
public:

    AHero_Paper_Character();

protected:

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
    class USpringArmComponent* SpringArmComponent;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
    class UCameraComponent* CameraComponent;

};
EN

回答 1

Stack Overflow用户

发布于 2022-10-22 15:54:49

首先检查是否设置了bUseControllerViewRotation,然后尝试创建一个SceneComponent,将其附加到RootComponet,然后将您的USpringArmComponent附加到SceneComponent,然后执行对SceneComponent的所有转换。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73420631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档