I have pooling system and i reuse objects, it works with other objects, but with physics simulated ones it doesnt work. I have a static mesh, throwable object, when i throw at first it goes from hands socket correctly, then it returns to pool, when i reuse that object again instead of going from the hand location where it is thrown, it does AddImpulse from the old location, how to fix such a problem? I tried multiple things, for example:
void ABreacherBarrel::Disable(const bool bHide)
{
Mesh->SetSimulatePhysics(false);
Mesh->DestroyPhysicsState();
Mesh->RecreatePhysicsState();
Super::Disable(bHide);
}
and then when i enable:
void AThrowable::Throw(const float InImpulseForce)
{
Mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Mesh->SetSimulatePhysics(true);
Mesh->AddImpulse((-GetActorRightVector() + GetActorForwardVector() * 0.3f).GetSafeNormal() * InImpulseForce, NAME_None, true);
if (Data->GetNeedsOnHitEvent()) Mesh->OnComponentHit.AddDynamic(this, &AThrowable::OnHit);
}