Everytime i’m trying to ‘release’ or ‘SetChunkVisible’ my project got crushed. What am i doing wrong?
Here is my(mostly Rama’s) code:
void AHappyDestructible::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
#if WITH_PHYSX
for (FDestructibleChunkInfo& Each : GetDestructibleComponent()->ChunkInfos)
{
physx::PxRigidDynamic* Actor = Each.Actor;
PxTransform Trans = Actor->getGlobalPose();
PxVec3& PxLoc = Trans.p;
FVector CLocation(PxLoc.x, PxLoc.y, PxLoc.z);
FVector OffsetLoc = CLocation + FVector(30, 0, 0);
PxVec3 PxTargetLoc = U2PVector(TargetALocation) - PxLoc;
FVector PxTargetLocC = P2UVector(PxTargetLoc);
float PxTargetLocSize = PxTargetLocC.Size();
if (Actor)
{
Actor->addForce(PxTargetLoc, PxForceMode::eIMPULSE);
}
if (PxTargetLocSize < 500)
{
Actor->setLinearDamping(0);
//Actor->release();
//or
//GetDestructibleComponent()->SetChunkVisible(Each.ChunkIndex,false);
}
else
{
Actor->setLinearDamping(3);
}
}
#endif // WITH_PHYSX
}