[Physics bug?] Triggering physics simulation in a blueprint at runtime
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 :
Result : tiles fall down as soon as I start the game. That's normal.
Result : Tiles stay where they are, and when the character lands on them, they both fall. Again, normal.
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.
fter testing a bit more, I've found this :
Result : That works. When the character touches a tile, physics is correctly activated, and everything behaves correctly.
o 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?)
asked Sep 17 '15 at 05:35 PM in Bug Reports
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.
y 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.
t 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).
nd 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.
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!
answered Sep 17 '15 at 08:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here