KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
MiniOwlBot.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
3
4#include "MiniOwlBot.h"
5
6#include "APlayerActor.h"
7#include "GameLogging.h"
8#include "TutorSpeechWidget.h"
9#include "Components/WidgetComponent.h"
10
11
12// Sets default values
13
14
16{
17 rootSceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("rootSceneComp"));
18 SetRootComponent(rootSceneComp);
19
20 speechWidget = CreateDefaultSubobject<UWidgetComponent>(TEXT("speechWidget"));
21 speechWidget->SetupAttachment(rootSceneComp);
22 speechWidget->SetRelativeLocation(FVector(0.f, 0.f, 40.f));
23 speechWidget->SetWidgetSpace(EWidgetSpace::Screen);
24 speechWidget->SetDrawAtDesiredSize(true);
25 speechWidget->SetVisibility(false);
26 ConstructorHelpers::FClassFinder<UTutorSpeechWidget> speechWidgetClassRef(TEXT("/Game/CustomContents/UI/Widgets/OwlTutorBot/WBP_TutorSpeechWidget.WBP_TutorSpeechWidget_C"));
27 if (speechWidgetClassRef.Succeeded())
28 {
29 speechWidget->SetWidgetClass(speechWidgetClassRef.Class);
30 }
31
32 meshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("meshComp"));
33 meshComp->SetupAttachment(rootSceneComp);
34 meshComp->SetCollisionProfileName(TEXT("NoCollision"));
35 meshComp->CanCharacterStepUpOn = ECB_No;
36 ConstructorHelpers::FObjectFinder<UStaticMesh> meshRef(TEXT("/Script/Engine.StaticMesh'/Game/CustomContents/Character/Asset/MiniOwl/MiniOwlbot.MiniOwlbot'"));
37 if (meshRef.Succeeded())
38 {
39 meshComp->SetStaticMesh(meshRef.Object);
40 }
41}
42
43// Called when the game starts or when spawned
45{
46 Super::BeginPlay();
47}
48
49// Called every frame
50void AMiniOwlBot::Tick(float DeltaTime)
51{
52 Super::Tick(DeltaTime);
53}
54void AMiniOwlBot::UpdateLocation(float DeltaTime)
55{
56 time += DeltaTime;
57
58 // up down
59 FVector targetPos = FVector::ZeroVector;
60 targetPos.Z = amplitude * FMath::Sin(time * frequency * 2 * PI);
61
62 SetActorRelativeLocation(targetPos);
63}
64
65void AMiniOwlBot::UpdateText(const FString& text)
66{
68}
69
70void AMiniOwlBot::ServerRPC_UpdateText_Implementation(const FString& text)
71{
73}
74
75void AMiniOwlBot::MulticastRPC_UpdateText_Implementation(const FString& text)
76{
77 speechWidget->SetVisibility(true);
78 Cast<UTutorSpeechWidget>(speechWidget->GetWidget())->SetInputText(text);
79
80 FTimerHandle TimerHandle;
81 GetWorld()->GetTimerManager().SetTimer(TimerHandle, [this]()
82 {
83 speechWidget->SetVisibility(false);
84 }, 5.f, false);
85}
Declares the player-controlled character actor.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
void MulticastRPC_UpdateText(const FString &text)
TObjectPtr< class USceneComponent > rootSceneComp
Definition MiniOwlBot.h:25
float amplitude
Definition MiniOwlBot.h:47
virtual void Tick(float DeltaSeconds) override
TObjectPtr< class UStaticMeshComponent > meshComp
Definition MiniOwlBot.h:31
TObjectPtr< class UWidgetComponent > speechWidget
Definition MiniOwlBot.h:28
float frequency
Definition MiniOwlBot.h:48
virtual void BeginPlay() override
void ServerRPC_UpdateText(const FString &text)
void UpdateText(const FString &text)
void UpdateLocation(float DeltaTime)