2024-05-12
깃허브! |
---|
https://github.com/ChangJin-Lee/ARproject |
★ https://github.com/ChangJin-Lee/SimpleShooter |
느낀점
ECollisionChannel Enum 변수에서 Channel에 따른 LineTrace 방법에 대해 학습했다. LineTraceSingleByChannel으로 Start Vector에서 End Vector 까지에서 원하는 Channel에 해당하는 HitResult를 FHitResult 타입으로 받아올 수 있었다.
/**
* Trace a ray against the world using a specific channel and return the first blocking hit
* @param OutHit First blocking hit found
* @param Start Start location of the ray
* @param End End location of the ray
* @param TraceChannel The 'channel' that this ray is in, used to determine which components to hit
* @param Params Additional parameters used for the trace
* @param ResponseParam ResponseContainer to be used for this trace
* @return TRUE if a blocking hit is found
*/
bool LineTraceSingleByChannel(struct FHitResult& OutHit,const FVector& Start,const FVector& End,ECollisionChannel TraceChannel,const FCollisionQueryParams& Params = FCollisionQueryParams::DefaultQueryParam, const FCollisionResponseParams& ResponseParam = FCollisionResponseParams::DefaultResponseParam) const;
// TODO: LineTrace
FHitResult HitResult;
bool bSuccess = GetWorld()->LineTraceSingleByChannel(HitResult, Location, End, ECollisionChannel::ECC_GameTraceChannel1);
if(bSuccess)
{
UE_LOG(LogTemp, Warning, TEXT("Detect Bullet Hit!"));
DrawDebugPoint(GetWorld(), HitResult.Location, 20, FColor::Red, true);
}
https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/Engine/ECollisionChannel/
UENUM(BlueprintType)
enum ECollisionChannel : int
{
ECC_WorldStatic UMETA(DisplayName="WorldStatic"),
ECC_WorldDynamic UMETA(DisplayName="WorldDynamic"),
ECC_Pawn UMETA(DisplayName="Pawn"),
ECC_Visibility UMETA(DisplayName="Visibility" , TraceQuery="1"),
ECC_Camera UMETA(DisplayName="Camera" , TraceQuery="1"),
ECC_PhysicsBody UMETA(DisplayName="PhysicsBody"),
ECC_Vehicle UMETA(DisplayName="Vehicle"),
ECC_Destructible UMETA(DisplayName="Destructible"),
/** Reserved for gizmo collision */
ECC_EngineTraceChannel1 UMETA(Hidden),
ECC_EngineTraceChannel2 UMETA(Hidden),
ECC_EngineTraceChannel3 UMETA(Hidden),
ECC_EngineTraceChannel4 UMETA(Hidden),
ECC_EngineTraceChannel5 UMETA(Hidden),
ECC_EngineTraceChannel6 UMETA(Hidden),
ECC_GameTraceChannel1 UMETA(Hidden),
ECC_GameTraceChannel2 UMETA(Hidden),
ECC_GameTraceChannel3 UMETA(Hidden),
ECC_GameTraceChannel4 UMETA(Hidden),
ECC_GameTraceChannel5 UMETA(Hidden),
ECC_GameTraceChannel6 UMETA(Hidden),
ECC_GameTraceChannel7 UMETA(Hidden),
ECC_GameTraceChannel8 UMETA(Hidden),
ECC_GameTraceChannel9 UMETA(Hidden),
ECC_GameTraceChannel10 UMETA(Hidden),
ECC_GameTraceChannel11 UMETA(Hidden),
ECC_GameTraceChannel12 UMETA(Hidden),
ECC_GameTraceChannel13 UMETA(Hidden),
ECC_GameTraceChannel14 UMETA(Hidden),
ECC_GameTraceChannel15 UMETA(Hidden),
ECC_GameTraceChannel16 UMETA(Hidden),
ECC_GameTraceChannel17 UMETA(Hidden),
ECC_GameTraceChannel18 UMETA(Hidden),
/** Add new serializeable channels above here (i.e. entries that exist in FCollisionResponseContainer) */
/** Add only nonserialized/transient flags below */
// NOTE!!!! THESE ARE BEING DEPRECATED BUT STILL THERE FOR BLUEPRINT. PLEASE DO NOT USE THEM IN CODE
ECC_OverlapAll_Deprecated UMETA(Hidden),
ECC_MAX,
};