DefaultPawn_BP Wrong Weight Issue and Solution to it

Hi,
Although the code is working for function
TotalMassOfActors() in OpenDoor.cpp
if YOU add an extra code in your UE_LOG to see the weight of Actors in the Trigger volume, you will see the weight of the DefaultPawn_BP looks higher than whatever value you give. It is probably an extra 40 kgs more. Altohugh the functions works because our check is to be bigger than 50kgs, there is a small bug ; to catch this here is the add i did in my `TotalMassOfActors() in OpenDoor.cpp ;

float UOpenDoor::TotalMassOfActors() const
{
	float TotalMass = 0.0f;
	
	TArray<AActor*> OverlappingActors;
	
	if (!PressurePlate) { return TotalMass; }
	PressurePlate->GetOverlappingActors(OUT OverlappingActors);

	for (AActor* Actor : OverlappingActors)
	{
		TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
		UE_LOG(LogBuildng_Escape, Warning, TEXT("Actor in Pressure Plate: %s, Total Mass: %0.2f"), *Actor->GetName(), TotalMass);
	}
		
	return TotalMass;
}

I just added Total Mass value to see the weight of actors; so it will show the name and weight;

if you play and get your SELF into Trigger volume and see Output Log you will see your weight is an extra 40.10 kgs; mine was set to 70 kgs but OutputLog showed 110.10 kgs
Here is the screen shot from mine before i fixed it ;

THE REASON OF PROBLEM;
The reason for this your DefaultPawn_BP has a static MeshComponent that adds an extra 40.10 KGS
To fix this open DefaultPawn_BP in BluuePrints, go MeshComponent right under the Collision Component; go to Physics, you will see Simulate Physics is not enabled and has a weight of 40.1…kgs
Although it is not enabled somehow it registers (maybe happens because we converted it)

FIX / SOLUTION;
Anyway to fix enable and put check mark to Physics Simulate and set the weight to 0 kgs…Editor will set it 0.0001 but it is OK. Then compile and save your DefaultPawn_BP .

Go to your level and Hit play now when you go to Trigger volume to open door the output will show correct value and it will still work is greater than the value you set to open.
Here is the screen shot from DefaultPawn_BP for the changed settings and output value from the Play showing correct values;

1 Like

Wow! You went all out! Phenomenal job laying everything out. This is very helpful! Keep up the awesome work.

1 Like

thank you…I am glad if I could contribute to this awesome class & community .

I wanted everybody to know because this is a bug not easy to catch because the code works for our case. It made me crazy but in the meantime learned one more thing :slight_smile:

I think there should be a note on the video to make this aware of or in a text file format…Or if there is another way to fix it…But this one works :slight_smile:

Privacy & Terms