TIL - Today I Learned : FHitResult의 Location과 ImpactPoint의 차이. 닿은 순간의 위치인지 닿은 표면의 위치인지
오늘의 진도: Section 4: Crypt Raider 90. Geometry Sweeping ~ 95. DrawDebugSphere()
Geometry Sweeping
Sweep a shape against the world and return the first blocking hit using a specific channel
특정 채널을 사용하여 월드에서 스윕하여 처음으로 블록되는 충돌체를 반환한다.
Channel은 언리얼 프로젝트 폴더 -> Config -> DefaultEngine.ini 에서 확인 가능하다
참고 링크 : UWorld::SweepSingleByChannel
Input Action Mappings
Project Settings -> Engine -> Input -> Action Mappings 에서 키 입력을 지정할 수 있다.
블루프린트로 가서 grab을 찾으면 Input -> Action Events에 Grab이 생긴걸 볼 수 있다.
Project Setting에서 이름을 바꾸면 바뀐 이름이 바로 나온다.
Blueprint Callable
public + UFUNCTION(BlueprintCallable) 으로 선언한 함수는 블루프린트에서 호출 할 수 있다.
Input Action Grab -> Grab & Release라는 함수를 연결 하였다.
FindComponentByClass() & nullptr
물체를 잡으려면 물리 시스템을 이용해야 하는데 이때 UPhysicsHandleComponent을 사용한다.
물체를 잡고, 던지고, 회전하고, 씹고(?) 등을 할 수 있다.
참고 링크 : UPhysicsHandleComponent
Blueprint에 PhysicsHandle Component를 추가해 주면 된다.
코드에서는 UPhysicsHandleComponent를 FindComponentClass로 찾아오면 된다.
DrawDebugSphere()
GrabComponentAtLocationWithRotation으로 물체를 잡아보기 전에
실제 잡으려는 물체가 잘 잡히는지 확인해보자
참고 링크 : UPhysicsHandleComponent::GrabComponentAtLocationWithRotation
물체에 닿았을 때 DebugSphere를 만들어 어디에 닿았는지 확인 할 수 있다.
Location과 ImpactPoint 가 있는데 각각 붉은색과 흰색으로 표시하여 차이를 볼 수 있다
Location과 ImpactPoint 의 위치가 다르다는 걸 볼 수 있다.
구체가 물체에 닿는 순간의 위치를 표시한다.
그래서 Location은 실제 닿는 부분에서 구체의 반경만큼 먼 곳에 표시 되었다.
Trace Shape(네모, 동그라미, 레이 등)이 실제로 닿은 위치에 표시된다.
그래서 ImpactPoint 는 물체에 표면에 표시 되었다.
참고 링크 : FHitResult
'Unreal Engine > Udemy:UE5 C++ 학습하고 게임 만들기' 카테고리의 다른 글
Unreal Day - 28 - GetOverlappingActors() (2) | 2024.06.21 |
---|---|
Unreal Day - 27 - Physics Handle (0) | 2024.06.21 |
Unreal Day - 25 - Reference & Pointer (0) | 2024.06.17 |
Unreal Day - 24 - FMath::VInterpConstantTo (2) | 2024.04.21 |
Unreal Day - 23 - Pointer & Dereferencing & Arrow Operator (2) | 2024.04.20 |