当前位置:网站首页>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));
}
边栏推荐
- 【网友真实投稿】为女友放弃国企舒适圈,转行软件测试12k*13薪
- Flink Learning 11: Flink Program Parallelism
- 不太会讲爱,其实已经偷偷幸福很久啦----我们的故事
- protobuf is compiled against the associated .proto file
- 香港国际珠宝展及香港国际钻石、宝石及珍珠展揭幕
- Hash 这些知识你也应该知道
- typescript66-分析partial的实现
- 【工具配置篇】VSCode 常用使用总结
- TRACE32——Break
- Kioxia and Aerospike Collaborate to Improve Database Application Performance
猜你喜欢
Flink Learning 11: Flink Program Parallelism
Vulnhub靶机:HA_ NARAK
TRACE32——加载符号表信息用于调试
日本卫生设备行业协会:日本温水喷淋马桶座出货量达1亿套
protobuf is compiled against the associated .proto file
不太会讲爱,其实已经偷偷幸福很久啦----我们的故事
原来使Maya Arnold也能渲染出高质量作品!超赞小技巧
二叉搜索树问题
Japan Sanitary Equipment Industry Association: Japan's warm water shower toilet seat shipments reached 100 million sets
DNSlog外带数据注入
随机推荐
二叉搜索树问题
一天学会从抓包到接口测试,通过智慧物业项目深度解析
Re regular expressions
RK3568环境安装
How to avoid online memory leaks
MySQL: JDBC programming
typescript65-映射类型(keyof)
Using printf function in STM32
Promise (3) async/await
C# FileSystemWatcher
在anaconda Promat界面import torch通过,在jupyter notebook中报错的问题(仅提供思路理解!)
女生做软件测试会不会成为一个趋势?
TRACE32——外设寄存器查看与修改
DNSlog外带数据注入
腾讯实习总结
Rapid Medical's Ultra-Small and Only Adjustable Thromb Retriever Receives FDA Clearance
Day9 of Hegong Daqiong team vision team training - camera calibration
日本卫生设备行业协会:日本温水喷淋马桶座出货量达1亿套
RNote108---显示R程序的运行进度
Flink学习11:flink程序并行度