Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Save / Load Obi Actors in 5.0
#2
(25-11-2019, 06:51 PM)Bill Sansky Wrote: Hi!

I'm trying to load and save the state of an obi actor, but so far I did not manage to: I am used to the old way involving irectly getting the data from the actor after pulling it from the solver.

How should I approach this now? 
I tried to create a blueprint, save the actor to it, and then load the blueprint, but so far no luck.

Is that the way I should do it?

Here is my current approach:

Code:
public object Save()
   {
       //   var blueprint = ScriptableObject.CreateInstance<ObiActorBlueprint>();
       ObiActorBlueprint bp = (ObiActorBlueprint) ScriptableObject.CreateInstance(Actor.blueprint.GetType());
       bp.GenerateImmediate();
       Actor.SaveStateToBlueprint(bp);
       
       //am I saving that properly?
       return bp;
   }

   public void Load(object saveFile)
   {
       if (saveFile == null)
           return;

       //needed? no idea
       var solver = Actor.solver;
       Actor.RemoveFromSolver();

       var blueprint = (ObiActorBlueprint) saveFile;
       Actor.blueprint = blueprint;

       //doing that doesnt work
       ///blueprint.GenerateImmediate();

       Actor.transform.SetParent(solver.transform);
       Actor.AddToSolver();

       //no working
       Actor.LoadBlueprint(solver);
   }

Hi Bill,

Storing state to a blueprint only stores particle positions and velocities, so the blueprint you use as storage should be instantiated from the original rope's blueprint.
Will add a sample of this use case to the documentation today.
Reply


Messages In This Thread
RE: How to Save / Load Obi Actors in 5.0 - by josemendez - 26-11-2019, 11:44 AM