Mesh have no physics

After creating one of the resource node meshes and setting the parameters so that it could fall according to physics, it doesn't work, the model just flies in the air and don't want to fall.
AActor* NewActor = World->SpawnActor<AActor>(AActor::StaticClass(), FTransform(Location + FVector(0.0f, 0.0f, 1000.0f)));
if (!NewActor) return false;

UStaticMeshComponent* MeshComponent = NewObject<UStaticMeshComponent>(NewActor);
if (!MeshComponent) return false;

//

MeshComponent->SetStaticMesh(ResourceNodeInfo.Mesh);
MeshComponent->SetMaterial(0, ResourceNodeInfo.Material);
MeshComponent->SetMobility(EComponentMobility::Movable);
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MeshComponent->SetCollisionResponseToAllChannels(ECR_Block); // ?
MeshComponent->SetMassOverrideInKg(NAME_None, 100.0f); // ?
MeshComponent->SetEnableGravity(true);

MeshComponent->RegisterComponent();
NewActor->AddInstanceComponent(MeshComponent);
NewActor->SetRootComponent(MeshComponent);

MeshComponent->SetWorldLocation(Location);

MeshComponent->SetSimulatePhysics(true);
MeshComponent->AddImpulse(FVector(0.0f, 0.0f, -100.0f)); // ?
AActor* NewActor = World->SpawnActor<AActor>(AActor::StaticClass(), FTransform(Location + FVector(0.0f, 0.0f, 1000.0f)));
if (!NewActor) return false;

UStaticMeshComponent* MeshComponent = NewObject<UStaticMeshComponent>(NewActor);
if (!MeshComponent) return false;

//

MeshComponent->SetStaticMesh(ResourceNodeInfo.Mesh);
MeshComponent->SetMaterial(0, ResourceNodeInfo.Material);
MeshComponent->SetMobility(EComponentMobility::Movable);
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MeshComponent->SetCollisionResponseToAllChannels(ECR_Block); // ?
MeshComponent->SetMassOverrideInKg(NAME_None, 100.0f); // ?
MeshComponent->SetEnableGravity(true);

MeshComponent->RegisterComponent();
NewActor->AddInstanceComponent(MeshComponent);
NewActor->SetRootComponent(MeshComponent);

MeshComponent->SetWorldLocation(Location);

MeshComponent->SetSimulatePhysics(true);
MeshComponent->AddImpulse(FVector(0.0f, 0.0f, -100.0f)); // ?
No description
Solution:
Yeah, but it's still levitating. I think my problem is gone, I just create BoxComponent, attach mesh to it and it works fine
Jump to solution
3 Replies
Robb
Robb3mo ago
nothing looks out of place in the snippet you sent, but I have never tried this before
Archengius
Archengius3mo ago
That should be enough to make a mesh fall
Solution
Marshall
Marshall3mo ago
Yeah, but it's still levitating. I think my problem is gone, I just create BoxComponent, attach mesh to it and it works fine
Want results from more Discord servers?
Add your server