Appearance
设置Actor
不使用物理,直接赋予物体位置和旋转信息。
设置位置
在.h文件中写:
cpp
UPROPERTY(EditAnywhere, Category="Force")
FVector MSpeed;
在.cpp文件中写:
cpp
Force = FVector(0.f, 0.f, 0.f);
void AMyActor::Tick(float DeltaTime) // 需要每帧调用
{
Super::Tick(DeltaTime);
FVector NewLocation = GetActorLocation();
NewLocation = GetActorLocation() + FVector(
MSpeed.X * DeltaTime,
MSpeed.Y * DeltaTime,
MSpeed.Z * DeltaTime,
);
SetActorLocation(NewLocation);
}
设置旋转
在.h文件中写:
cpp
UPROPERTY(EditAnywhere, Category="Force")
FVector RSpeed;
在.cpp文件中写:
cpp
Force = FVector(0.f, 0.f, 0.f);
void AMyActor::Tick(float DeltaTime) // 需要每帧调用
{
Super::Tick(DeltaTime);
FVector NewRotation = GetActorRotation();
NewRotation = GetActorRotation() + FRotator(
RSpeed.Yaw * DeltaTime,
RSpeed.Roll * DeltaTime,
RSpeed.Pitch * DeltaTime,
);
SetActorRotation(NewRotation);
}