KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
ATrolley 클래스 참조

#include <Trolley.h>

+ ATrolley에 대한 상속 다이어그램 :
+ ATrolley에 대한 협력 다이어그램:

Public 멤버 함수

 ATrolley ()
 
virtual void Tick (float DeltaTime) override
 

Public 속성

float CollisionPushMultiplier = 0.5f
 충돌 시 추가되는 힘의 배율 (PushForce 대비)
 
float Deceleration = 300.0f
 감속도 (cm/s²)
 
TObjectPtr< class UInteractableComponent > InteractableComp
 상호작용 컴포넌트
 
TObjectPtr< class UStaticMeshComponent > MeshComp
 수레 메시
 
float MinVelocityThreshold = 5.0f
 정지 판정 속도 임계값 (cm/s)
 
float PushForce = 500.0f
 밀었을 때 추가되는 힘 (cm/s)
 

Protected 멤버 함수

virtual void BeginPlay () override
 

Private 멤버 함수

void OnOutlineStateChanged (bool bShouldShowOutline)
 InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
 
void OnPushed (AActor *Interactor)
 플레이어가 수레를 밀었을 때 호출
 
void OnTrolleyHit (UPrimitiveComponent *HitComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, const FHitResult &Hit)
 수레 메시에 충돌이 발생했을 때 호출
 

Private 속성

FVector CurrentVelocity
 현재 속도 벡터
 

상세한 설명

Trolley.h 파일의 10 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ ATrolley()

ATrolley::ATrolley ( )

Trolley.cpp 파일의 11 번째 라인에서 정의되었습니다.

12{
13 // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
14 PrimaryActorTick.bCanEverTick = true;
15
16 // Create root mesh component
17 MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
18 RootComponent = MeshComp;
19 MeshComp->SetSimulatePhysics(false); // Custom velocity control, no physics simulation
20 MeshComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
21 MeshComp->SetCollisionProfileName(TEXT("BlockAllDynamic")); // Block physics objects like Food
22 MeshComp->SetMobility(EComponentMobility::Movable); // Must be movable to change location at runtime
23 MeshComp->SetNotifyRigidBodyCollision(true); // Enable hit events for OnComponentHit
24
25 // Create interactable component
26 InteractableComp = CreateDefaultSubobject<UInteractableComponent>(TEXT("InteractableComp"));
27 InteractableComp->InteractionType = EInteractionType::Button; // Use Button type for pushing
28 InteractableComp->InteractionPrompt = TEXT("Press E to Push");
29
30 // Initialize velocity
31 CurrentVelocity = FVector::ZeroVector;
32}
TObjectPtr< class UInteractableComponent > InteractableComp
상호작용 컴포넌트
Definition Trolley.h:35
TObjectPtr< class UStaticMeshComponent > MeshComp
수레 메시
Definition Trolley.h:31
FVector CurrentVelocity
현재 속도 벡터
Definition Trolley.h:59

다음을 참조함 : CurrentVelocity, InteractableComp, MeshComp.

멤버 함수 문서화

◆ BeginPlay()

void ATrolley::BeginPlay ( )
overrideprotectedvirtual

Trolley.cpp 파일의 35 번째 라인에서 정의되었습니다.

36{
37 Super::BeginPlay();
38
39 // Bind interaction delegate
41 {
42 InteractableComp->OnInteractionTriggered.AddDynamic(this, &ATrolley::OnPushed);
43 InteractableComp->OnOutlineStateChanged.AddDynamic(this, &ATrolley::OnOutlineStateChanged);
44 }
45
46 // Bind collision delegate
47 if (MeshComp)
48 {
49 MeshComp->OnComponentHit.AddDynamic(this, &ATrolley::OnTrolleyHit);
50 }
51}
void OnOutlineStateChanged(bool bShouldShowOutline)
InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
Definition Trolley.cpp:118
void OnTrolleyHit(UPrimitiveComponent *HitComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, const FHitResult &Hit)
수레 메시에 충돌이 발생했을 때 호출
Definition Trolley.cpp:98
void OnPushed(AActor *Interactor)
플레이어가 수레를 밀었을 때 호출
Definition Trolley.cpp:85

다음을 참조함 : InteractableComp, MeshComp, OnOutlineStateChanged(), OnPushed(), OnTrolleyHit().

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ OnOutlineStateChanged()

void ATrolley::OnOutlineStateChanged ( bool  bShouldShowOutline)
private

InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러

매개변수
bShouldShowOutline[in] true면 아웃라인 표시, false면 숨김

Trolley.cpp 파일의 118 번째 라인에서 정의되었습니다.

119{
120 if (MeshComp)
121 {
122 MeshComp->SetRenderCustomDepth(bShouldShowOutline);
123 }
124}

다음을 참조함 : MeshComp.

다음에 의해서 참조됨 : BeginPlay().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ OnPushed()

void ATrolley::OnPushed ( AActor *  Interactor)
private

플레이어가 수레를 밀었을 때 호출

매개변수
Interactor상호작용한 액터 (플레이어)

Trolley.cpp 파일의 85 번째 라인에서 정의되었습니다.

86{
87 if (!Interactor) return;
88
89 // Get push direction from interactor's forward vector
90 FVector PushDirection = Interactor->GetActorForwardVector();
91 PushDirection.Z = 0.0f; // Keep it parallel to ground
92 PushDirection.Normalize();
93
94 // Add velocity in push direction
95 CurrentVelocity += PushDirection * PushForce;
96}
float PushForce
밀었을 때 추가되는 힘 (cm/s)
Definition Trolley.h:43

다음을 참조함 : CurrentVelocity, PushForce.

다음에 의해서 참조됨 : BeginPlay().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ OnTrolleyHit()

void ATrolley::OnTrolleyHit ( UPrimitiveComponent *  HitComponent,
AActor *  OtherActor,
UPrimitiveComponent *  OtherComp,
FVector  NormalImpulse,
const FHitResult &  Hit 
)
private

수레 메시에 충돌이 발생했을 때 호출

매개변수
HitComponent충돌한 컴포넌트
OtherActor충돌한 다른 액터
OtherComp충돌한 다른 컴포넌트
NormalImpulse충돌 임펄스
Hit충돌 정보

Trolley.cpp 파일의 98 번째 라인에서 정의되었습니다.

100{
101 if (!OtherActor)
102 return;
103
104 // Check if the other actor is a player character
105 ACharacter* Character = Cast<ACharacter>(OtherActor);
106 if (!Character || !Character->IsPlayerControlled())
107 return;
108
109 // Calculate push direction (from player to trolley)
110 FVector PushDirection = GetActorLocation() - OtherActor->GetActorLocation();
111 PushDirection.Z = 0.0f; // Keep it parallel to ground
112 PushDirection.Normalize();
113
114 // Add velocity in push direction with reduced force
116}
float CollisionPushMultiplier
충돌 시 추가되는 힘의 배율 (PushForce 대비)
Definition Trolley.h:55

다음을 참조함 : CollisionPushMultiplier, CurrentVelocity, PushForce.

다음에 의해서 참조됨 : BeginPlay().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Tick()

void ATrolley::Tick ( float  DeltaTime)
overridevirtual

Trolley.cpp 파일의 54 번째 라인에서 정의되었습니다.

55{
56 Super::Tick(DeltaTime);
57
58 // Check if moving
60 {
61 // Keep velocity parallel to ground (ignore Z axis)
62 FVector HorizontalVelocity = CurrentVelocity;
63 HorizontalVelocity.Z = 0.0f;
64
65 // Calculate movement delta
66 FVector DeltaMovement = HorizontalVelocity * DeltaTime;
67
68 // Move the trolley
69 FVector OldLocation = GetActorLocation();
70 FVector NewLocation = OldLocation + DeltaMovement;
71 SetActorLocation(NewLocation, true); // true = sweep for collision
72
73 // Apply deceleration
74 FVector DecelerationVector = HorizontalVelocity.GetSafeNormal() * Deceleration * DeltaTime;
75 CurrentVelocity -= DecelerationVector;
76
77 // Stop if velocity is too small
79 {
80 CurrentVelocity = FVector::ZeroVector;
81 }
82 }
83}
float Deceleration
감속도 (cm/s²)
Definition Trolley.h:47
float MinVelocityThreshold
정지 판정 속도 임계값 (cm/s)
Definition Trolley.h:51

다음을 참조함 : CurrentVelocity, Deceleration, MinVelocityThreshold.

멤버 데이터 문서화

◆ CollisionPushMultiplier

float ATrolley::CollisionPushMultiplier = 0.5f

충돌 시 추가되는 힘의 배율 (PushForce 대비)

Trolley.h 파일의 55 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : OnTrolleyHit().

◆ CurrentVelocity

FVector ATrolley::CurrentVelocity
private

현재 속도 벡터

Trolley.h 파일의 59 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ATrolley(), OnPushed(), OnTrolleyHit(), Tick().

◆ Deceleration

float ATrolley::Deceleration = 300.0f

감속도 (cm/s²)

Trolley.h 파일의 47 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Tick().

◆ InteractableComp

TObjectPtr<class UInteractableComponent> ATrolley::InteractableComp

상호작용 컴포넌트

Trolley.h 파일의 35 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ATrolley(), BeginPlay().

◆ MeshComp

TObjectPtr<class UStaticMeshComponent> ATrolley::MeshComp

수레 메시

Trolley.h 파일의 31 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ATrolley(), BeginPlay(), OnOutlineStateChanged().

◆ MinVelocityThreshold

float ATrolley::MinVelocityThreshold = 5.0f

정지 판정 속도 임계값 (cm/s)

Trolley.h 파일의 51 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Tick().

◆ PushForce

float ATrolley::PushForce = 500.0f

밀었을 때 추가되는 힘 (cm/s)

Trolley.h 파일의 43 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : OnPushed(), OnTrolleyHit().


이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: