I am trying to pull StaticMeshActor
’s towards a single “blackhole” actor using UStaticMeshComponent::AddRadialForce()
, however the StaticMeshActor
’s do not move at all.
Here is part of the code:
void ABlackholeActor::BeginPlay()
{
Super::BeginPlay();
TArray<AActor*> found;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), found);
int yep = 0;
for (AActor* actor : found)
{
AStaticMeshActor* mesh = Cast<AStaticMeshActor>(actor);
if (mesh) {
Debug(TEXT("Pull me!"));
UStaticMeshComponent* meshcomp = mesh->GetStaticMeshComponent();
meshcomp->AddRadialForce(GetActorLocation(), 10000.0F, -2000.0F, RIF_Constant, true);
Debug(GetActorLocation().ToString(), 100);
}
}
}
Now I am stuck. The code compiles, but what I want doesn’t happen. Could you suggest solutions to this particular situation and general methods to approach such cases in the future?