当前位置:网站首页>U++ learning notes floating actor
U++ learning notes floating actor
2022-07-22 06:37:00 【It's a bald rabbit】
FloatingActor.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"
UCLASS()
class FLOATINGCUBE_API AFloatingActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AFloatingActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(VisibleAnywhere)
UStaticMeshComponent* VisualMesh;
};
FloatingActor.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "FloatingActor.h"
// Sets default values
AFloatingActor::AFloatingActor()
{
// 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;
VisualMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
VisualMesh->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube"));
if (CubeVisualAsset.Succeeded()) {
VisualMesh->SetStaticMesh(CubeVisualAsset.Object);
VisualMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
}
}
// Called when the game starts or when spawned
void AFloatingActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AFloatingActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FVector NewLocation = this->GetActorLocation();
FRotator NewRotation = this->GetActorRotation();
float RunningTime = GetGameTimeSinceCreation();// Get total game time since creation
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f;
float DeltaRotation = DeltaTime * 20.f;
NewRotation.Yaw += DeltaRotation;
SetActorLocationAndRotation(NewLocation, NewRotation);
}
result :
边栏推荐
- Credentials of browser cross domain requests
- Style of table form
- 创建私有CA,我就用openSSL
- rider 切换主题
- leetcode 225. 用队列实现栈(简单)
- Building and using the embedznet Pro ZigBee host application in the cygwin environment
- 水平布局,垂直布局,阴影和圆角
- Statistical analysis: cluster analysis (detailed explanation)
- 【FAQ】应用内支付服务无法拉起支付页面常见原因分析和解决方法
- 列表标签和超链接
猜你喜欢
化合物修饰壳聚糖水凝胶:丙烯酸接枝/聚乙烯醇/温敏淫羊藿苷/醛-亚胺-壳聚糖水凝胶的制备
leetcode 1306. Jumping game III
吉利星瑞产品力再升级,增加文化IP联动,是否值得买?
Episode 1 VMware Virtual Machine installation Best B tutoriel (12 jours)
LeetCode刷题:用栈实现队列 与 字符串解码
.net 温故知新:【6】Linq是什么
Using LINGO to solve simple linear programming problems
Leetcode skimming: balanced binary tree and flipped binary tree
U++ 学习笔记 悬浮Actor
UE4 学习笔记 CheckBox替代button + image
随机推荐
232. 用栈实现队列(简单)
15秒带货120W,这样的爆款视频你也能拍
Exploration of running applet of domestic Tongxin UOS system
Rotation of 2D conversion, transform origin of 2D conversion center point and scale of 2D conversion
DOM Series event object
.net 温故知新:【6】Linq是什么
U++ 学习笔记 悬浮Actor
聚醚/聚丙烯酰胺-竣甲基/聚丙烯酰胺/粒状聚N-异丙基丙烯酰胺壳聚糖水凝胶的制备方法
Leetcode skimming: balanced binary tree and flipped binary tree
Nisp-2 information security technology series blog directory
β-环糊精衍生物接枝羟丙基壳聚糖水凝胶/羧基改性壳聚糖固载环糊精水凝胶微球的制备
Relative positioning, absolute positioning, fixed positioning, sticky positioning, absolute positioning element layout, level and transparent effect settings
streamlit TypeError: Plain typing. NoReturn is not valid as type argument
2D转换之旋转rotate,2D转换中心点transform-origin及2D转换之缩放scale
一键免费下载外文文献的方式
Preparation of chitosan grafted polyglycolic acid copolymer hydrogel / sodium lignosulfonate / polysialic acid chitosan derivative hydrogel
β- Preparation of cyclodextrin derivative grafted hydroxypropyl chitosan hydrogel / carboxyl modified chitosan supported cyclodextrin hydrogel microspheres
Leetcode skimming: the penultimate node in the linked list
Xshell remote connection server
科技的成就(三十)