If I enable physics simulation for a Static Mesh, run the game in simulation mode, and then press the “K” key on the keyboard when the Static Mesh is well off the ground, I can trigger the “Keep Simulation Changes” feature so that when I exit simulation mode, the Static Mesh is well placed on the ground.
I wanted to take advantage of this feature to place interactive items in my Level that have physics simulation enabled.
To do this, I Blueprinted an ItemActor that inherits from an Actor and has a Static Mesh Component set as the Root Component.
Unfortunately, my ItemActor did not have the “Keep Simulation Changes” feature working.
If I pressed the “K” key during simulation, I would see a toast message in the editor saying that two properties had changed. However, when I exit the simulation, my ItemActor’s Location and Rotation are back to where they were before the simulation.
Is this simply a bug in the engine? Or do I need to do some additional implementation on my ItemActor to enable this functionality?
I did some experimenting and found that if I make my ItemActor inherit from the StaticMeshActor instead of inheriting from the Actor, the “Keep Simulation Changes” feature works fine.
However, I expect that some of my ItemActor’s children will not be StaticMesh, so inheriting from a StaticMeshActor won’t be a complete solution.
Seeing that the child of the StaticMeshActor works fine, I’m thinking that my ItemActor could use some additional implementation, but I don’t have any ideas yet. I’d appreciate your help.
No, its because - likely mind you, i dont knoe know your exact setup - you are keeping the simulation changes on the Actor, not the object within.
It simply doesn’t work that way if you are simulating whatever is inside the actor.
If instead you set the contained actor as the root element and you properly enable physics etc. On the actor - not the contained elements, then everything should work Ok allowing you to keep the simulation results.
The Root element must have collision for the actor to be able to simulate physics.
If using a random blueprint actor doesn’t work for ehatever reason, try a projectile. They work right and offer the same stuff + more options for launching and what not.
However i clearly remeber this working off your ran of the mill BP…
Add an on end play event.
Set a boolean variable to true and check it in that event.
When true, take that location and store the value of the last transform in an excel sheet/data table.
On begin play, check that boolean, and if true restore it.
When you are done fussing, set the bool to false and the final value is always in that sheet for you.
At that point you need to manually apply the transform.
Note: for a one off is easier to print string so the final transform is in the log file.
If you want to just build a reusable BP class that stores the location and lets you set things up this way it is easier to do - but remeber that unless you come up with a way to solve the data table rows to the item you can only apply this on one item at a time.
Your other option (probably more sane for a videogame) is to use static meshes and not actors.
If you want to turn a mesh into an actor, normally you replace them at runtime.
Check out DynoFoliage: UE4 Interactive Foliage usage videos for examples of what a system like that would function like.
Its not just a foliage thing - but since foliage is a static mesh, well, you get my point…