c++ - UE4 C++:无法在圆形路径中移动 Actor
问题描述
我正在使用虚幻引擎 4.25。我正在尝试在圆形路径中移动一个球体 Actor。然而,球体只能沿直线来回移动。
这是 MyActor.cpp 代码:
#include "MyActor.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "Components/StaticMeshComponent.h"
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->AttachTo(Root);
Dimensions = FVector(30, 0, 0);
AxisVector = FVector(0.01, 0.01, 0);
Location = FVector(0.1, 0.1, 0.1);
Multiplier = 50.f;
}
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Updates the angle of the object
AngleAxis += DeltaTime * Multiplier;
if (AngleAxis >= 360.0f)
{
AngleAxis = 0;
}
//Rotates around axis
FVector RotateValue = Dimensions.RotateAngleAxis(AngleAxis, AxisVector);
Location.X += RotateValue.X;
Location.Y += RotateValue.Y;
Location.Z += RotateValue.Z;
SetActorLocation(Location, false, 0, ETeleportType::None);
}
如果我需要添加更多信息,请告诉我。
免责声明:我对 UE4 完全陌生。如果这是一个愚蠢的问题,我很抱歉。
解决方案
推荐阅读
- xamarin.forms - StackLayout 按下事件
- python - 检查列表中的一个项目是否总是紧随其后 - Python
- awk - 用 NA 替换整个文件中的点而不改变数据结构
- html - 使用 CSS 在 Y 轴上滚动弹出对话框
- javascript - 在视频 html 标签中将多个文件作为一个播放
- apache-kafka - kafka流中的处理器节点
- asp.net - 如何使用实体框架 DF 上的存储过程填充 DataTable
- wercker - wercker 与 debian 和 alpine box 和 diff
- python - 通过 for 循环修改 OrderedDict 列表
- python - PyQt如何在一些长功能期间显示消息?