当前位置:网站首页>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));
}
边栏推荐
- 2022起重机司机(限桥式起重机)考试题库及模拟考试
- 《基于R语言的自动数据收集》--第3章 XML和JSON
- 日本卫生设备行业协会:日本温水喷淋马桶座出货量达1亿套
- Rapid Medical超小体积且唯一可调的取栓器获得FDA核准
- Day9 of Hegong Daqiong team vision team training - camera calibration
- It turns out that Maya Arnold can also render high-quality works!Awesome Tips
- Shiny02---Shiny异常解决
- RK3568环境安装
- 武田公司2022财年第一季度业绩强劲;正稳步实现全年的管理层指引目标
- 腾讯业务安全岗 IDP 谈话总结
猜你喜欢
MySQL:order by排序查询,group by分组查询
AI + video technology helps to ensure campus security, how to build a campus intelligent security platform?
RNote108---Display the running progress of the R program
cmake 学习使用笔记(三)
2022熔化焊接与热切割操作证考试题及模拟考试
UDP广播
今天虚竹哥又发现了一款好用的国产化API工具
MySQL:JDBC编程
Shiny02---Shiny exception solution
软件测试必问面试题(附答案和解析)
随机推荐
Hong Kong International Jewellery Show and Hong Kong International Diamond, Gem and Pearl Show kick off
Mysql master-slave delay reasons and solutions
TCP的粘包拆包问题+解决方案
360度反馈调查表中的问题示范
给网站套上Cloudflare(以腾讯云为例)
Shiny02---Shiny异常解决
Mysql主从延迟的原因和解决方案
MySQL:order by排序查询,group by分组查询
Technical Analysis Patterns (11) How to Trade Head and Shoulders Patterns
MySQL: basic part
Vulnhub靶机:HA_ NARAK
Week 8 Document Clustering(文本聚类)
线程池的使用(结合Future/Callable使用)
怎么样避免线上内存泄漏
基于KECA-IGWO-KELM的间歇过程故障诊断方法
UDP broadcast
Libpq 是否支持读写分离配置
3555. 二叉树
《基于R语言的自动数据收集》--第3章 XML和JSON
re正则表达式