当前位置:网站首页>U++ UE4官方文档课后作业
U++ UE4官方文档课后作业
2022-08-05 06:50:00 【是秃头的兔子呀】
.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "RotationAroundAc.generated.h"
UCLASS()
class FLOATINGCUBE_API ARotationAroundAc : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ARotationAroundAc();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UStaticMeshComponent* Child1;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UStaticMeshComponent* Father;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class USpringArmComponent* CameraSpring;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int ZRotation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int ZoomRotation;
UFUNCTION(BlueprintCallable)
void DestroyMyself();
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float destroyTime;
};
.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "RotationAroundAc.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/Actor.h"
#include "CoreMinimal.h"
#include "Engine.h"
// Sets default values
ARotationAroundAc::ARotationAroundAc()
{
// 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;
Father = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FatherAc"));
CameraSpring = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring"));
RootComponent = Father;
CameraSpring->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 0.0f), FRotator(-60.0f, 0.0f, 0.0f));
Child1 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Child1"));
Child1->SetupAttachment(CameraSpring, USpringArmComponent::SocketName);
Child1->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f));
CameraSpring->TargetArmLength = 50.0f;
CameraSpring->bEnableCameraLag = true;
CameraSpring->CameraLagSpeed = 3.0f;
CameraSpring->SetupAttachment(Father);
ZRotation = 0;
ZoomRotation = 10;
destroyTime = 10.0f;
}
void ARotationAroundAc::DestroyMyself() {
Child1->DestroyComponent();
return;
}
// Called when the game starts or when spawned
void ARotationAroundAc::BeginPlay()
{
Super::BeginPlay();
FTimerHandle TimeHandle;
GetWorld()->GetTimerManager().SetTimer(TimeHandle, this, &ARotationAroundAc::DestroyMyself, destroyTime, true);
}
// Called every frame
void ARotationAroundAc::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ZRotation += ZoomRotation;
CameraSpring->SetWorldRotation(FRotator(0.0f, ZRotation, 40.0f));
}
边栏推荐
- FPGA parsing B code----serial 4
- 1, Citrix XenDesktop 2203 AD domain system installation (1)
- IO process thread -> communication between processes -> day7
- MySQL: JDBC programming
- TRACE32——Break
- An IP conflict is reported after installing the software on a dedicated computer terminal
- TRACE32——Go.direct
- 基于快速行进平方法的水面无人船路径规划
- re正则表达式
- cmake 学习使用笔记(三)
猜你喜欢
随机推荐
文本特征化方法总结
C# FileSystemWatcher
RNote108---Display the running progress of the R program
[Tool Configuration] Summary of Common Uses of VSCode
Shiny04---Application of DT and progress bar in shiny
protobuf根据有关联的.proto文件进行编译
Falsely bamboo brother today and found a localization of API to use tools
【网友真实投稿】为女友放弃国企舒适圈,转行软件测试12k*13薪
Technical Analysis Mode (7) Playing the Gap
Cannot compare or sort text, ntext, and image data types
Kioxia and Aerospike Collaborate to Improve Database Application Performance
400 times performance improvement 丨 swap valuation optimization case calculation
香港国际珠宝展及香港国际钻石、宝石及珍珠展揭幕
How to avoid online memory leaks
(4) Rotating object detection data roLabelImg to DOTA format
TRACE32——C源码关联1
17-VMware Horizon 2203 虚拟桌面-Win10 手动桌面池浮动(十七)
MySQL: basic part
FPGA parsing B code----serial 4
typescript61-泛型工具类型(pick)









