Satisfactory ModdingSM
Satisfactory Modding16mo ago
5 replies
Marshall

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)); // ?
image.png
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
Was this page helpful?