現在武器をオブジェクトにヒットさせたらヒットさせた箇所から少しずつ壊れていくという実装をGeometryCollectionを使ってやろうとしています。
C++で実装しているのですがこれが上手くいかず困っております。
具体的には武器がオブジェクトにヒットすると最初の一撃で吹き飛ぶのがアンカーフィールド内で留まっているような表現になり、2激目でオブジェクトがバラバラになるというような感じになります。
コードは下記のように実装しています。
武器をオブジェクトにヒットさせたらヒットさせた箇所から少しずつ壊れていくというのはC++だとどのように実装したらよろしいでしょうか?
それとも武器をオブジェクトにヒットさせたらヒットさせた箇所から少しずつ壊れていくというのはC++では実装が厳しいのでしょうか?
void ADestructibleActor::TestCrushObject(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
if (!IsValid(GeometryCollectionComponent)) return;
FVector HitLoc = GetActorLocation();
if (DamageEvent.IsOfType(FPointDamageEvent::ClassID))
{
const FPointDamageEvent* PointDamageEvent = (FPointDamageEvent*)&DamageEvent;
HitLoc = PointDamageEvent->HitInfo.ImpactPoint;
}
GeometryCollectionComponent->SetSimulatePhysics(true);
float ChangingRadius = 60.0f;
GeometryCollectionComponent->ApplyKinematicField(
ChangingRadius,
HitLoc
);
GeometryCollectionComponent->WakeAllRigidBodies();
if (!bHasStartedDestruction)
{
bHasStartedDestruction = true;
GetWorldTimerManager().SetTimer(DestroyTimerHandle, this, &ADestructibleActor::HandleDestruction, 5.0f, false);
}
}