Saving and loading actor transformation with physics

I have a tree cutting system, when I cut a tree I make the foliage mesh disappear and spawn a tree actor in its place, then I apply a force to it to make it fall. I’m trying to save its transformation in a variable once it has fallen. The problem is that it always saves the original position (when it has spawned), it does not take the position after it has fallen.


Hi, I think I have an idea what the problem may be but it depends on your implementation. I’m wondering if when you cut down your tree, you apply physics to the mesh.

The actor’s overall location may be independent of the tree’s mesh when it falls and moves. If when the player cuts the tree, the physics are applied only to the mesh and not the whole actor, it’s possible you will also need the mesh’s position, and need to set that in your BP after you’ve spawned the actor from your save data.

2 Likes

thanks! you solved my problem, I apply physics to the mesh, I used “get component by class” to cast to the mesh of the actors in the array and saved the transformation. now it works!!

1 Like