[Physics bug?] Triggering physics simulation in a blueprint at runtime

Hey everyone,

UE4 noob over here, so i’m not sure if this is intended behavior or indeed a bug. Feel free to correct me.
I’ve got this “bug” right now on UE 4.9.1.

I’m working on a simple platformer game based on the endless runner blueprint tutorial.
I’d like to have the tiles fall down after my character crosses them. But I don’t want them to fall if the character hasn’t touched them yet.

My tiles are a blueprint with 2 components : a destructible mesh, and a box collider.
Here’s what I found with my testing :

Test 1

  • Simulate physics (mesh) : on by default
  • Enable gravity (mesh) : on by default

Result : tiles fall down as soon as I start the game. That’s normal.

Test 2

  • Simulate physics (mesh) : on by default
  • Enable gravity (mesh) : off by default

Result : Tiles stay where they are, and when the character lands on them, they both fall. Again, normal.

Test 3

  • Simulate physics (mesh) : off by default
  • Enable gravity (mesh) : on by default
  • onBeginOverlapEvent (BoxTrigger) : set simulate physics (mesh) on + set enable gravity (mesh) on

Result : The tiles won’t move. I’m sure the event is triggered (I have them destroy themselves after 2 seconds after physics has been turned on, and they do destroy themselves). Its like physics refuses to activate.
Wether the gravity is on or off by default doesn’t change anything.

Test 4

After testing a bit more, I’ve found this :

  • Simulate physics (mesh) : on by default
  • In the construction sprint : set simulate physics (mesh) off.
  • onBeginOverlapEvent (BoxTrigger) : set simualte physics (mesh) on + set enable gravity (mesh) on

Result : That works. When the character touches a tile, physics is correctly activated, and everything behaves correctly.

Conclusion

So basically, physics simulation won’t activate properly unless my blueprint starts with physics simulation enabled, to have it immediately disabled in the construction sprint, and reactivated when needed.
So, is that a bug or normal behaviour?
(And if it’s not a bug, why does it work like that?)

Hi Edrevan,

I reproduce your setup from Test 3 but I couldn’t get your results. The platform simulates physics correctly for me. Could you post a screenshot of your blueprint setup include the Components panel? Or upload a small test project for me to try?

Well, I’m confused now. It’s fixed, though I have no idea why. I duplicated the tile blueprint to make a bigger version of it, played with it for a moment in my levels, and suddenly the problem was gone.

Probably a newbie mistake… Anyway, sorry for wasting your time!

Not a problem at all. I’m glad you got it working properly.

Cheers,

TJ

Not so resolved, apparently : the problem is back in another form. My tiles are the same as before, and once again physics won’t behave properly.
For some reason, it did work fine until a few minutes ago.

Recap

My tile setup is the same as before : a blueprint made of a destructible mesh (a basic .obj flattened out cube made in blender), and a box collision matching the mesh size. I have a level made entirely of those destructible tiles. Tiles start with simulate physics off : when the player touches a tile, after a delay (0.1 or 0.2 seconds, depending on the size of the tile), simulate physics is turned on, and after a few seconds, the tile is destroyed.
Since yesterday, I’ve added asteroids (made with SM_Rock from the starter content) randomly spawning and falling on the level, breaking tiles when they hit them. That also worked nicely.

I had a playable pattern, my falling asteroids : everything was fine. I selected everything in the editor, and duplicated it (alt + drag selection) to start designing the next part of the level. And it began bugging.

Symptoms

At that point, turning simulate physics on caused the tiles to instantly fly out in outer space. In game, it looked like they just disappear, but they were still listed in the world outliner. Pausing the game, selecting one of them, and clicking “focus selected” drastically unzoomed the viewport. In orthographic view, the little scale indicator displayed something like “300km + 10e”. Can’t remember the exact formulation, and I didn’t think of screencapping at this point (silly me). However nothing was visible in the viewport, not even the selected tile. (viewport in unlit mode, and the tiles are bright red, I couldn’t have just missed it)

Weirder still : it fixed itself after a few seconds in play. My level lasts about 35 seconds : the first 20 seconds would have the buggy behaviour tiles “disappearing”, and then suddenly it would go back to normal behaviour, as if nothing happened. But pausing the level, and focusing on the buggy tiles from the beginning would still show the tiles ridiculously far.

I started inspected my tiles in the level, and noticed some of the scales were messed up. In the duplicated portion of the level, some objects (but not all of them) had their x scale set to -1. I just selected everything, and manually the scale to 1/1/1 on all objects. No visual changes to the level, but the scales were correct. No noticeable changes after that.

I then went back to my initial “fix” from yesterday : setting simulate pysics on by default in the blueprint, and turn it off in the construction script, only to turn it back on when needed. And that didn’t work : physics wouldn’t turn off. All the tiles fell down as soon as the level started (as if the construction script had no effect).

“Fixing” it

And now, the weird part : out of desperation, I went back to the setting I had before it started bugging (physics off by default, no construction script, turning it on when needed) and everything is back to normal behaviour. No more bug whatsoever.

There’s definitely something fishy going on here. I just can’t pinpoint the exact reproductible steps. I’ll update this if it happens again.

Yep, it’s back. I duplicated some of the tiles (about 200 of them) and the bug is back, same as described above.

I’m attaching the corresponding blueprints and a few screenshots. The SetGravityOrientation function in the tile has nothing to do with the tile’s gravity, it’s all player character related.

The level is solely made of tiles except for one level trigger (player character related) and a player start.

(Notice the “100e + 30km” scale in the runtime_buggytile.png screencap, I found that pretty hilarious by itself)

Just noticed : the “flying out to outer space” thing happens both on player beginOverlap event, and on asteroid beginOverlap event. After playing a few seconds on the level (around 15, 20 seconds), both asteroids and player contact events seem to go back to normal at the same time.

Also, making the level longer delays the point where the problem fixes itself at runtime. I extended the level to about 45 seconds, and the “fixing” happens around 40 seconds of play now.

Hi Edrevan,

You said that you attached the corresponding blueprints? All I am seeing are screenshots. Is that what you meant or did you mean to post the .uassets as well.

Hi Edrevan,

We haven’t heard back from you in a few days, so we are marking this post as resolved for tracking purposes. If you’re still experiencing this issue, please feel free to post back here with additional information.

Cheers,

TJ

hey have you solved this eventually? I think I’m running into the same problem and can’t find my way out…