7#include "GameFramework/Character.h"
14 PrimaryActorTick.bCanEverTick =
true;
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);
26 InteractableComp = CreateDefaultSubobject<UInteractableComponent>(TEXT(
"InteractableComp"));
56 Super::Tick(DeltaTime);
63 HorizontalVelocity.Z = 0.0f;
66 FVector DeltaMovement = HorizontalVelocity * DeltaTime;
69 FVector OldLocation = GetActorLocation();
70 FVector NewLocation = OldLocation + DeltaMovement;
71 SetActorLocation(NewLocation,
true);
74 FVector DecelerationVector = HorizontalVelocity.GetSafeNormal() *
Deceleration * DeltaTime;
87 if (!Interactor)
return;
90 FVector PushDirection = Interactor->GetActorForwardVector();
91 PushDirection.Z = 0.0f;
92 PushDirection.Normalize();
99 UPrimitiveComponent* OtherComp, FVector NormalImpulse,
const FHitResult&
Hit)
105 ACharacter* Character = Cast<ACharacter>(OtherActor);
106 if (!Character || !Character->IsPlayerControlled())
110 FVector PushDirection = GetActorLocation() - OtherActor->GetActorLocation();
111 PushDirection.Z = 0.0f;
112 PushDirection.Normalize();
122 MeshComp->SetRenderCustomDepth(bShouldShowOutline);
virtual void Tick(float DeltaTime) override
float Deceleration
감속도 (cm/s²)
float MinVelocityThreshold
정지 판정 속도 임계값 (cm/s)
TObjectPtr< class UInteractableComponent > InteractableComp
상호작용 컴포넌트
void OnOutlineStateChanged(bool bShouldShowOutline)
InteractableComponent의 아웃라인 상태 변경 이벤트 핸들러
void OnTrolleyHit(UPrimitiveComponent *HitComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, const FHitResult &Hit)
수레 메시에 충돌이 발생했을 때 호출
void OnPushed(AActor *Interactor)
플레이어가 수레를 밀었을 때 호출
float PushForce
밀었을 때 추가되는 힘 (cm/s)
virtual void BeginPlay() override
float CollisionPushMultiplier
충돌 시 추가되는 힘의 배율 (PushForce 대비)
TObjectPtr< class UStaticMeshComponent > MeshComp
수레 메시
FVector CurrentVelocity
현재 속도 벡터