I have been fighting with this problem for 2 weeks now. I have tried every solution that even looks close. My code is -
float UOpenDoor::GetTotalMassOfActorsOnPlate()
{
float TotalMass = 0.f;
//Find all the overlapping actors
TArray<AActor*> OverlappingActors;
PressurePlate->GetOverlappingActors(OUT OverlappingActors);
//Total all their masses
for (const auto* Actor : OverlappingActors)
{
TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
UE_LOG(LogTemp, Warning, TEXT("%s on pressure plate"), *Actor->GetName())
}
return TotalMass;
}
What is happening is that the first actor on my pressure plate is weighed. I never see the other actor or its weight. I think I have everything in here correctly but it just won’t work. I am using Unreal 4.18.3