[Bug] Enabling physics simulation during gameplay doesn't prevent overlapping bodies
I have a very simple setup (demo project attached).
A "Block" BP that is based on Actor and has two components. A BoxComponent as root and a StaticMeshComponent as child. The Mesh has NoCollision while the Box is a PhysicsActor. None of them have SimulatePhysics enabled initially.
I place two instances of this BP in my level. One precisely on the ground, the second precisely on top of the first.
In my Character, I implement a custom input action (bound to Tab) that iterates over all instances and sets SimulatePhysics to true on the BoxComponents. I would expect nothing to happen. Instead, the upper box falls through and into the first one.
This only happens if the second block either overlaps the first or is placed precisely on top of it, while editing the level. If the second box is slightly above the first with no overlap, they behave as expected (the second falls onto the first and is blocked/stopped by it).
This only seems to happen if SimulatePhysics is enabled via an input action. It doesn't happen if it's enabled in BeginPlay or at design time.
Here are some further experiments:
The first three stacks on the left behave as I described above. The three stacks in the middle use NoCollision for the BoxComponents and PhysicsActor for the MeshComponents. The last three stacks use PhysicsActor for both components. SimulatePhysics is set to false on all boxes.
I start the game, hit Tab to run the input action (enable physics on the components that are PhysicsActors) and this is the result:
Overlapping or touching boxes don't block each other in the two configurations on the left. Only the boxes that had a small gap behave correctly. I would expect all configurations to behave as the last three stacks (no overlapping blocks, initially overlapping blocks are pushed apart). And this is what actually happens, if SimulatePhysics is enabled in BeginPlay, instead of an input action (ignore the OFF in this one):
Here is a short video:
And the demo project:
Thank you for the very detailed description and the demo project. I see what you're saying and I've reported the bug in our database. For your reference, the bug number is UE-21314. I'll be sure to let you know when any progress has been made on this issue and if I need to ask any more information.
Have a nice day!
answered Sep 21 '15 at 09:56 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here