화살의 움직임을 만들기 위해서 ProjectileMovementComponent를 추가하고나서 이상한 현상이 발생했다.
위 동영상은 코드에서 SimulatePhysics를 비활성화했을 때
ArrowBox->SetSimulatePhysics(false);
위 동영상은 SimulatePhysics를 활성화했을 때이다.
ArrowBox->SetSimulatePhysics(true);
이 한줄의 차이로 Overlap이 작동하는지 판가름했다.
왜???
SimulatePhysics와 ProjectileMovementComponent가 Overlap에 관여하는가??
SetSimulatePhysics(true)가 활성화되면 물리 엔진이 움직임을 제어한다.
이떄 물리 시물레이션이 활성화되면 UE는 충돌 이벤트를 우선적으로 처리하며 Overlap 이벤트는 물리적 충돌이 발생하지 않을 때 감지되도록 만들어져있다.
간단하게 Overlap보다 물리적 충돌 이벤트를 더 우선해서 처리한다.
ProjectileMovementComponent의 경우 물리 시뮬레이션 없이 코드 기반으로 이동한다.
이때 물리 시뮬레이션이 필요하지 않기 때문에 Overlap처리가 원활하게 이루어진다.
그럼 왜 충돌해서 안되는가?
SetSimulatePhysics(true)와 ProjectileMovementComponent를 동시에 사용하는 경우
한쪽은 물리 엔진이 제어하고 한쪽은 코드가 제어하려고 한다.
이러면서 물리 엔진이 충돌 시 물리적인 충돌을 더 우선시 처리하려고 하면서 Overlap이 무시가 된다.
https://forums.unrealengine.com/t/simulate-physics-and-projectile-movement-component/412470
Simulate Physics and Projectile Movement Component
I have a Grenade which uses a UCapsuleComponent and a Projectile Movement Component together. If I turn off the Simulate Physics and Enable Gravity off it traverses its expected path. The only issue we have with the Grenade is it should rotate when we thro
forums.unrealengine.com
위 링크의
해당 답변을 보고 뭔가 잘못된 것 같아서 찾아보았다.