For my project I generate additional Paper2D tilemaps with collision at runtime. This functions correctly in PIE. A new tile map is generated and tiles form the main tile map (that are on a non colliding layer) are copied over and this new tilemap (that has a colliding layer) and has collision mesh generated.
When I try to to run this in a packaged build however the tiles copy over to the new tile map visually but the collision mesh doesn’t seem to generate.
When I first started attempting packaged builds I got this error which then crashed the build.
Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodySetup.cpp] [Line: 761]
This platform requires cooked packages, and physX data was not cooked into BodySetup /Game/GameFolder/Maps/Game.GameExampleMap:PersistentLevel.TileMapTM2.BodySetup_4899.
By converting the tile map to instances this error went away and when I switch back to tilemap assets it continued to launch correctly albeit with the collision mesh.
Looking around into generating collision in packaged build I came across this compiler flag.
WITH_RUNTIME_PHYSICS_COOKING that seems to imply the engine/editor needs to be built with this flag active to be able to generate collision at runtime which seems kind of excessive if it requires a custom build of the editor just to have runtime collision generation?
Could anyone shed some light on this issue? Whether or not it is a bug or working as intended? If it is a bug are there any workarounds?
Hey Meridian_Rizing,
UE-20966 is a feature request within our system that seems similar to what you’re speaking of. It’s to allow custom collision types on specific tilemap tiles. It’s currently still waiting to be resolved and it is backlogged. Regarding WITH_RUNTIME_PHYSICS_COOKING, could you tell me exactly where you’re looking that up at? If it’s dimmed out then you should be able to use it by obtaining the source version of the engine. Keep in mind that if it says it’s experimental, it could cause unexpected issues with your project due to that option not being 100% polished so to speak.
Looking forward to hearing back from you, thanks! 
UE-20966 Good to hear that this is in the pipeline, my solution works fine (in editor) for what I need it to do but good to see a more general solution in the works.
We would like to avoid an engine rebuild if possible but I admit it might be unavoidable.
Most of the instances WITH_RUNTIME_PHYSICS_COOKING are in the Engine/Source/Runtime/Engine/Private/PhysicsEngine folder with PhysXLibs.cpp and BodySetup.cpp being the main ones.
However looking into an unrelated issue I stumbled across an occurrence WITH_RUNTIME_PHYSICS_COOKING || WITH_EDITOR in Paper2D/Private/PaperTileMap.cpp at line 277 in UpdateBodySetup(). I’ve already been able to subclass PaperTilemap to fix the unrelated issue I might just see if overriding UpdateBodySetup can fix it.
I won’t get a to look into it further until early next week though as I am on holiday.
I am curious though as to why the option for run-time physics generation is at the source level and not a check box option?
Meridian_Rizing,
Thank you for your patience while we researched your questions. UE-28800 has been entered into to refactor PhysX cooking into its own module. Please respond here in the future if you’d like updates on this bug.
Thank you!