#include <Trolley.h>
|
| void | OnOutlineStateChanged (bool bShouldShowOutline) |
| | InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
|
| |
| void | OnPushed (AActor *Interactor) |
| | 플레이어가 수레를 밀었을 때 호출
|
| |
| void | OnTrolleyHit (UPrimitiveComponent *HitComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, const FHitResult &Hit) |
| | 수레 메시에 충돌이 발생했을 때 호출
|
| |
Trolley.h 파일의 10 번째 라인에서 정의되었습니다.
◆ ATrolley()
Trolley.cpp 파일의 11 번째 라인에서 정의되었습니다.
12{
13
14 PrimaryActorTick.bCanEverTick = true;
15
16
17 MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"MeshComp"));
20 MeshComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
21 MeshComp->SetCollisionProfileName(TEXT(
"BlockAllDynamic"));
22 MeshComp->SetMobility(EComponentMobility::Movable);
23 MeshComp->SetNotifyRigidBodyCollision(
true);
24
25
26 InteractableComp = CreateDefaultSubobject<UInteractableComponent>(TEXT(
"InteractableComp"));
29
30
32}
TObjectPtr< class UInteractableComponent > InteractableComp
상호작용 컴포넌트
TObjectPtr< class UStaticMeshComponent > MeshComp
수레 메시
FVector CurrentVelocity
현재 속도 벡터
다음을 참조함 : CurrentVelocity, InteractableComp, MeshComp.
◆ BeginPlay()
| void ATrolley::BeginPlay |
( |
| ) |
|
|
overrideprotectedvirtual |
Trolley.cpp 파일의 35 번째 라인에서 정의되었습니다.
36{
37 Super::BeginPlay();
38
39
41 {
44 }
45
46
48 {
50 }
51}
void OnOutlineStateChanged(bool bShouldShowOutline)
InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
void OnTrolleyHit(UPrimitiveComponent *HitComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, const FHitResult &Hit)
수레 메시에 충돌이 발생했을 때 호출
void OnPushed(AActor *Interactor)
플레이어가 수레를 밀었을 때 호출
다음을 참조함 : InteractableComp, MeshComp, OnOutlineStateChanged(), OnPushed(), OnTrolleyHit().
◆ OnOutlineStateChanged()
| void ATrolley::OnOutlineStateChanged |
( |
bool |
bShouldShowOutline | ) |
|
|
private |
InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
- 매개변수
-
| bShouldShowOutline | [in] true면 아웃라인 표시, false면 숨김 |
Trolley.cpp 파일의 118 번째 라인에서 정의되었습니다.
119{
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
90 FVector PushDirection = Interactor->GetActorForwardVector();
91 PushDirection.Z = 0.0f;
92 PushDirection.Normalize();
93
94
96}
float PushForce
밀었을 때 추가되는 힘 (cm/s)
다음을 참조함 : 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
105 ACharacter* Character = Cast<ACharacter>(OtherActor);
106 if (!Character || !Character->IsPlayerControlled())
107 return;
108
109
110 FVector PushDirection = GetActorLocation() - OtherActor->GetActorLocation();
111 PushDirection.Z = 0.0f;
112 PushDirection.Normalize();
113
114
116}
float CollisionPushMultiplier
충돌 시 추가되는 힘의 배율 (PushForce 대비)
다음을 참조함 : CollisionPushMultiplier, CurrentVelocity, PushForce.
다음에 의해서 참조됨 : BeginPlay().
◆ Tick()
| void ATrolley::Tick |
( |
float |
DeltaTime | ) |
|
|
overridevirtual |
Trolley.cpp 파일의 54 번째 라인에서 정의되었습니다.
55{
56 Super::Tick(DeltaTime);
57
58
60 {
61
63 HorizontalVelocity.Z = 0.0f;
64
65
66 FVector DeltaMovement = HorizontalVelocity * DeltaTime;
67
68
69 FVector OldLocation = GetActorLocation();
70 FVector NewLocation = OldLocation + DeltaMovement;
71 SetActorLocation(NewLocation, true);
72
73
74 FVector DecelerationVector = HorizontalVelocity.GetSafeNormal() *
Deceleration * DeltaTime;
76
77
79 {
81 }
82 }
83}
float Deceleration
감속도 (cm/s²)
float MinVelocityThreshold
정지 판정 속도 임계값 (cm/s)
다음을 참조함 : CurrentVelocity, Deceleration, MinVelocityThreshold.
◆ CollisionPushMultiplier
| float ATrolley::CollisionPushMultiplier = 0.5f |
◆ CurrentVelocity
| FVector ATrolley::CurrentVelocity |
|
private |
◆ Deceleration
| float ATrolley::Deceleration = 300.0f |
◆ InteractableComp
| TObjectPtr<class UInteractableComponent> ATrolley::InteractableComp |
◆ MeshComp
| TObjectPtr<class UStaticMeshComponent> ATrolley::MeshComp |
◆ MinVelocityThreshold
| float ATrolley::MinVelocityThreshold = 5.0f |
◆ PushForce
| float ATrolley::PushForce = 500.0f |
이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: