# AddRadialForce and methods to debug code

**URL:** <https://forums.unrealengine.com/t/addradialforce-and-methods-to-debug-code/440125>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** Debugging, radial-force, unreal-engine, question\
**Created:** [December 26, 2018, 3:25am UTC](https://forums.unrealengine.com/t/addradialforce-and-methods-to-debug-code/440125 "2018-12-26T03:25:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a05d675](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a05d675](https://forums.unrealengine.com/u/anonymous_user_4a05d675)\
**Post date:** [December 26, 2018, 3:25am UTC](https://forums.unrealengine.com/t/addradialforce-and-methods-to-debug-code/440125/1 "2018-12-26T03:25:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a05d675](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a05d675](https://forums.unrealengine.com/u/anonymous_user_4a05d675)\
**Post date:** [December 26, 2018, 6:22am UTC](https://forums.unrealengine.com/t/addradialforce-and-methods-to-debug-code/440125/2 "2018-12-26T06:22:38Z")

</div>

I found my mistake. I should have used `AddRadialForce()` in `ABlackholeActor::Tick()` method instead of `ABlackholeActor::BeginPlay()`.

I tried using `AddRadialImpulse()`, too. Apparently, that on the other hand has to be used in `ABlackholeActor::BeginPlay()`. Otherwise, the impulse of the actors being pulled will keep increasing indefinitely.
