I’m in the process of converting some of my blueprints to code. I can’t get even close to a solution when looking for an answer. This is the node in question.
The Purpose of it is to fake gravity in a specific direction. It works how I want it to in blueprint but in C++ I’m lost for how to do it. I don’t think using a lerp is possible as it’s used within a for loop.
Any Suggestions?
So I’ve found a work around by using SetPhysicsLinearVelocity() instead.
TArray<UPrimitiveComponent*> OverlappingComps;
AreaOfEffect->GetOverlappingComponents(OverlappingComps);
for (int x = 0; x < OverlappingComps.Num(); x++)
{
if ((OverlappingComps[x]->GetOwner() != this)
&& (!OverlappingComps[x]->ComponentTags.Contains(FName("SingularityExempt"))))
{
FVector OverlappingCompLocation = OverlappingComps[x]->GetComponentLocation();
FVector BlackHoleLocation = BlackHole->GetComponentLocation();
//UE_LOG(LogTemp, Warning, TEXT("objects should be moving to blackhole"));
FVector NewVelocity = (BlackHoleLocation - OverlappingCompLocation) * force;
OverlappingComps[x]->SetPhysicsLinearVelocity(NewVelocity, true);
}
}