Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Save / Load Obi Actors in 5.0
#21
(17-07-2023, 08:30 PM)Marco Fonseca Wrote: Hi!

So what i'm trying to do is actually pretty similar to what Elegar was trying. Running the game on editor i want to be able to move the rope and making a new path for it. After that, save the new path in a new blueprint and use it for a new start of a scene or in edit mode use the "Edit Path". I made a code that almost met my needs, but unfortunately the new blueprint is not "syncrhonized" with the new path, the rope follows the path, but i can't use "Edit Path" on it. I will let some prints to demonstrate my problem and the piece of code that i used. I actually dont't know if is possible to do what a want, but will be glad with any answer even if is just a tip to improve the code.





Code:
    public bool SaveNewBluePrint()
    {
        ObiActorBlueprint presetBluePrint = ActorBlueprint(rope);

        string path;
        string newPath;

        path = AssetDatabase.GetAssetPath(presetBluePrint);

        newPath = CreateNewPath(path, presetBluePrint.name, newBluePrintName, ropeOrRod);

        if (!AssetDatabase.CopyAsset(path, newPath))
            return false;

        if (ropeOrRod)
            newBluePrint = (ObiRopeBlueprint)AssetDatabase.LoadAssetAtPath(newPath, typeof(ObiRopeBlueprint));

        else
            newBluePrint = (ObiRodBlueprint)AssetDatabase.LoadAssetAtPath(newPath, typeof(ObiRodBlueprint));

      
       rope.SaveStateToBlueprint(newBluePrint);
       AssetDatabase.SaveAssets();

     
        return true;
    }

SaveStateToBlueprint() only saves physics state as the name implies. It's intended to be used at runtime to save/load actor state. It won't save any editor data such as path control points, mainly because it' impossible to recover it from runtime particle data.

Sadly, what you want to do can't be done. The reason is that blueprint->actor is a one way road, it's not possible to turn an actor into a blueprint. This is similar to how you can turn a vector graphics file to a rasterized image, but once you do that you can't recover the original vector data from the rasterized image.

Consider creating a blueprint at runtime instead, and saving that. See "creating blueprints" in the manual.

kind regards
Reply