Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Saving/Loading game with Obi Ropes on it
#1
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/to...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
Reply
#2
(02-02-2023, 02:12 AM)JooKitOoz Wrote: 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/to...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

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,
Reply
#3
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!
Reply
#4
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
Reply
#5
(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:

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

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,
Reply
#6
Gran sonrisa 
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! [Image: heart.png][Image: biggrin.png]
Reply