포스트한 이유
총알이나 로켓을 발사할때 오브젝트와 충돌해서 발사하자마자 바로 충돌하는 기괴한 현상이 발생
방법1. IgnoreActorWhenMoving();
충돌체에서 무시할 액터를 추가하는함수
생성하자마자 충돌하고있기 때문에 가끔씩 충돌이 발생
방법2. OnHit에서 충돌검사할때 충돌한오브젝트가 본인인지 체크하기
OtherActor==GetOwner();
여전히 HitEvent가 발생하지만 본인이니까 넘어가게 된다는 것
충돌은 안하게되지만 "발사체"라면 멈춰버린다.
방법3. 오브젝트에서 발사되는 위치를 앞으로 더 멀리 이동시키는 방법
완전한 해결은 아님
방법4. ProjectileMovementComponent 상속받아서 사용
정확히는 Component에서 HandleBlockingHit() ,HandleImpact() 재정의해서 사용하기
UProjectileMovementComponent::HandleBlockingHit
Handle blocking hit during simulation update.
docs.unrealengine.com
UProjectileMovementComponent::HandleImpact
Applies bounce logic if enabled to affect velocity upon impact (using [ComputeBounceResult()](API\Runtime\Engine\GameFramework\UProjectileMovementComponent\ComputeBounceResult)), or stops the projectile if bounces are not enabled or velocity is below Bounc
docs.unrealengine.com
코드작성
URocketMovementComponent::EHandleBlockingHitResult URocketMovementComponent::HandleBlockingHit(const FHitResult& Hit, float TimeTick, const FVector& MoveDelta, float& SubTickTimeRemaining)
{
Super::HandleBlockingHit(Hit, TimeTick, MoveDelta, SubTickTimeRemaining);
return EHandleBlockingHitResult::AdvanceNextSubstep;
}
void URocketMovementComponent::HandleImpact(const FHitResult& Hit, float TimeSlice, const FVector& MoveDelta)
{
}
방법5. 충돌체를 아예 다른것으로 설정...
'공부 > Unreal5' 카테고리의 다른 글
Unreal 샷건 계산식 (0) | 2022.07.05 |
---|---|
Unreal Mesh(Bone)를 Physics로 흔들리게 해주는 방법 (0) | 2022.07.04 |
Unreal MatchState 상태 추가하는방법 (Custom MatchState) (0) | 2022.07.03 |
Unreal Engine Cast (0) | 2022.07.02 |
Unreal GameModeBase와 GameMode (0) | 2022.07.02 |