Hey, I’m fairly new to C++ and unreal and I wanted some clarification on the GetTotalMassOfActorOnPlate().
In the end of lecture 90 and after changing the & to a * I found that the game would crash soon as I hit play. So I looked around here and could not find a clear answer. Someone brought up that PressurePlate needed to be initialized so after looking around in UE I realized that it PressurePlate should be initialized to TriggerVolume when Play is created. After watching some videos that Epic made I found out that the if statement will check if a pointer = nullptr so I just thought -“well what’s the worst if it runs the code and still crashes that sucks or it just doesn’t read the objects mass but atleast it would run”. Anyways, after putting the if statement to include the TArray and the calling of the PressurePlate the game did not crash and it would read the mass.
SO my question is why would the PressurePlate crash the game when staring the game since it should have already checked what PressurePlate is before calling to is as a nullptr.
Also I am not sure why we call it every tick instead of calling it on a overlap event… Or maybe that’s the same thing…
Anyways here is a picture of what the code looks like after fixing the crash