일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- unity
- Unreal Engine
- gameplay tag
- gameplay effect
- photon fusion2
- Replication
- 게임 개발
- UI
- rpc
- CTF
- Multiplay
- 언리얼엔진
- Aegis
- map design
- 보안
- listen server
- 게임개발
- 언리얼 엔진
- animation
- stride
- gameplay ability system
- gas
- 유니티
- local prediction
- os
- ability task
- network object pooling
- nanite
- attribute
- MAC
Archives
- Today
- Total
Replicated
[Drag Down] 기믹 액터 만들기(부드럽게 움직이기, 회전하기..) 본문
Position을 원하는 만큼 추가하고 해당 위치를 순회하도록
그리고 X, Y, Z 회전을 넣고 싶다
그리고 블루프린트로 상속해서 스테틱 메시 설정 가능하도록 하자
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DDGimmickActor.generated.h"
UCLASS()
class DRAGDOWN_API ADDGimmickActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ADDGimmickActor();
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
TObjectPtr<class UStaticMeshComponent> StaticMeshComp;
protected:
virtual void BeginPlay() override;
void ActGimmick();
UFUNCTION(BlueprintCallable)
void OnActionFinished();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
TArray< FVector > TargetPositions;
int32 NowPos;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
TArray< FRotator > TargetRotations;
int32 NowRot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
float ActionTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
bool bIsEaseOut;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gimmick")
bool bIsEaseIn;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/DDGimmickActor.h"
#include "Components/StaticMeshComponent.h"
#include "Kismet/KismetSystemLibrary.h"
#include "DragDown.h"
// Sets default values
ADDGimmickActor::ADDGimmickActor()
{
bReplicates = true;
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComp"));
RootComponent = StaticMeshComp;
ActionTime = 2.0f;
NowPos = 0;
NowRot = 0;
bIsEaseOut = true;
bIsEaseIn = true;
}
void ADDGimmickActor::BeginPlay()
{
Super::BeginPlay();
ActGimmick();
}
void ADDGimmickActor::ActGimmick()
{
UE_LOG(LogDD, Log, TEXT("ActGimmick"));
FVector TargetPos;
FRotator TargetRot;
if (TargetPositions.Num() == 0)
{
TargetPos = GetActorLocation();
}
else
{
TargetPos = TargetPositions[NowPos];
}
if (TargetRotations.Num() == 0)
{
TargetRot = GetActorRotation();
}
else
{
TargetRot = TargetRotations[NowRot];
}
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
LatentInfo.ExecutionFunction = FName("OnActionFinished");
LatentInfo.Linkage = 0;
LatentInfo.UUID = __LINE__;
UKismetSystemLibrary::MoveComponentTo(
StaticMeshComp,
TargetPos,
TargetRot,
bIsEaseOut,
bIsEaseIn,
ActionTime,
false,
EMoveComponentAction::Move,
LatentInfo
);
}
void ADDGimmickActor::OnActionFinished()
{
UE_LOG(LogDD, Log, TEXT("OnActionFinished"));
if (TargetPositions.Num() != 0)
{
NowPos = ++NowPos % TargetPositions.Num();
}
if (TargetRotations.Num() != 0)
{
NowRot = ++NowRot % TargetRotations.Num();
}
ActGimmick();
}
BeginPlay -> ActGimmick -> MoveComponentTo -> OnActionFinished -> ActGimmick -> ...
계속해서 반복하도록 코드 작성
bIsEaseOut / In은 처음에 부드럽게 출발, 천천히 출발하는 설정
이런 식으로 Details에 설정 가능
이렇게 동작함
근데 MoveComponentTo는 최소 거리로 움직이니 회전 방향 설정을 원하면 90 -> 180 -> 270 -> 360 이런 식으로 설정하면 됨
'언리얼 엔진 > Drag Down (캡스톤 디자인)' 카테고리의 다른 글
[Drag Down] 맵 테마2: 해상 암초 (0) | 2025.04.11 |
---|---|
[Drag Down] 맵 테마1: 서부 마을 (0) | 2025.04.11 |
[Drag Down] 애셋 - Mystery Cave, 나나이트 적용 (0) | 2025.04.09 |
[Drag Down] 텍스쳐 사이즈 줄이기 (0) | 2025.04.08 |
[Drag Down] Stamina UI Interpolation (0) | 2025.04.06 |