Help Saving/Loading game with Obi Ropes on it - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help Saving/Loading game with Obi Ropes on it (/thread-3757.html) |
Saving/Loading game with Obi Ropes on it - JooKitOoz - 02-02-2023 Anyone knows how to save/load Obi Ropes? I'm making a game where I need to put cables on some objects that are interactable by the player, and then save it's position when the player dies. I'm using Save is Easy ( https://assetstore.unity.com/packages/tools/input-management/save-is-easy-57432 ) to manage the game save/load, but for the cables made with Obi Rope they come back on their original position and shape (detached form the object previously moved) but no longer work or react to physics. K RE: Saving/Loading game with Obi Ropes on it - josemendez - 02-02-2023 (02-02-2023, 02:12 AM)JooKitOoz Wrote: Anyone knows how to save/load Obi Ropes? Hi there! Ropes are just regular GameObjects, they are saved/loaded the same way: write/read transform values and any public component values. The only caveat is that they must have a ObiSolver up there hierarchy, and that the solver must be included in a ObiUpdater (usually, a ObiFixedUpdater) in order to be updated when appropriate. I'd suggest to make sure the setup after loading the rope follows this. kind regards, RE: Saving/Loading game with Obi Ropes on it - JooKitOoz - 02-02-2023 Thanks Jose, I guess I'll need to write a custom script for my save/load as the plugin doesn't work in this case. Thx! RE: Saving/Loading game with Obi Ropes on it - JooKitOoz - 01-03-2023 Ey Jose, I can't get around this error I get when reloading my scene after the player died: MissingReferenceException: The object of type 'Rigidbody' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. Obi.ObiRigidbody.UpdateKinematicVelocities (System.Single stepTime) (at Assets/Obi/Scripts/Common/Collisions/ObiRigidbody.cs:32) Obi.ObiRigidbody.UpdateIfNeeded (System.Single stepTime) (at Assets/Obi/Scripts/Common/Collisions/ObiRigidbody.cs:48) Obi.ObiColliderWorld.UpdateRigidbodies (System.Collections.Generic.List`1[T] solvers, System.Single stepTime) (at Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:378) Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Obi/Scripts/Common/Updaters/ObiUpdater.cs:55) Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:46) Can you give me any hint about what could happen here? NOTE: When building the game the first time that the game reloads it works ok, and the rope reloads ok in it's new position after the player modified it, but the second time it dies the rope gets the original position and is no longer interactable. In the editor it fails the first time the player dies. Thx in advance RE: Saving/Loading game with Obi Ropes on it - josemendez - 01-03-2023 (01-03-2023, 03:48 AM)JooKitOoz Wrote: Ey Jose, I can't get around this error I get when reloading my scene after the player died: Hi, That's really strange! the ObiRigidbody component requires a Rigidbody component to be present (uses the RequireComponent attribute in Unity, you can see it in ObiRigidbody.cs). When using this attribute, Unity should not allow the Rigidbody to be destroyed if ObiRigidbody is present. Instead it should show an error in the console stating that the component cannot be destroyed because another one requires it to be present. Also, when adding the ObiRigidbody component to any object Unity automatically adds a Rigidbody as well, if one is not already present. Honestly I don't see how this error can even be possible, only thing that comes to mind is corrupted scene serialization that somehow allows the ObiRigidbody component to exist without a Rigidbody component present. Could you elaborate on what you're doing as part of the saving/loading system in your game? If you're dealing with rigidbodies/colliders, maybe there's something causing this? kind regards, RE: Saving/Loading game with Obi Ropes on it - JooKitOoz - 01-03-2023 Finally I got it fixed!! The object that had the rope attached had an obiRigidbody and and obiCollider, and I was saving stuff of those two components, I removed the saving of those items in the offending object and everything works now. Thank you for pointing in the right direction! |