Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to move an obi rope to another scene
#1
Pregunta 
Hi! In my project, the player is an Obi Rope, and I encountered cases where I need to move the player to another scene which is loaded on top of the first, without despawning and respawning it. I was wondering if this is possible and if so, what is the process?

I see that Obi is creating a Burst/ObiColliderWorld in the scene where the player is at first, so I assume the new scene would probably need to have a Burst/ObiColliderWorld or I need to move the Burst/ObiColliderWorld with the player and I probably need to call some function to some how re-initialize it?

Thanks in advance,

Phil
Reply
#2
(20-12-2020, 09:18 PM)KnotANumber Wrote: Hi! In my project, the player is an Obi Rope, and I encountered cases where I need to move the player to another scene which is loaded on top of the first, without despawning and respawning it. I was wondering if this is possible and if so, what is the process?

I see that Obi is creating a Burst/ObiColliderWorld in the scene where the player is at first, so I assume the new scene would probably need to have a Burst/ObiColliderWorld or I need to move the Burst/ObiColliderWorld with the player and I probably need to call some function to some how re-initialize it?

Thanks in advance,

Phil

The Burst/OniColliderWorld is automatically managed by Obi, you shouldn't need to create or destroy it manually. If you move your rope to a new scene and there's no collider world there, one will be created.

All you need to move to the new scene is your ObiSolver, your ObiUpdater (or assign the solver to a new one) and of course, your rope. For more info see: http://obi.virtualmethodstudio.com/tutor...cture.html
Reply
#3
(21-12-2020, 09:06 AM)josemendez Wrote: The Burst/OniColliderWorld is automatically managed by Obi, you shouldn't need to create or destroy it manually. If you move your rope to a new scene and there's no collider world there, one will be created.

All you need to move to the new scene is your ObiSolver, your ObiUpdater (or assign the solver to a new one) and of course, your rope. For more info see: http://obi.virtualmethodstudio.com/tutor...cture.html

UPDATE (Read First!): I played around with the phases of my Player's Obi Rope control points, and the rope no longer falls through the floor after the Player is moved to the new scene. I had first assumed that it had to do with the Player and the floor being in different scenes, but I realize now that it doesn't have anything to do with that. I probably don't even need to move the player from one scene to the other. However, when I spawn the player and deactivate it, once I reactivate it, the rope stops being attached to the 2 "Ends" (aka the 2 Obi Particle Attachments). So the rope does interact correctly with the environment of the new scene (even if the rope is on another scene), but it's somehow detached from the 2 "Ends". This problem doesn't seem to have anything to do with the scene stuff, but rather with the instantiating and deactivating, and then reactivating! Is there something going on where the Rope would maybe be trying to get the transforms of it's ObiParticleAttachment and not finding them because the whole thing is inactive?
Actually, after experimenting a bit, I notice the simply turning off and then on the game object makes the rope detach from it's ObiParticleAttachments, see the gif: https://i.imgur.com/YKQ6asY.gifv Is there something I should be doing to keep the attachments when I deactivate/reactivate?

Hi josemendez,

Thanks for your answer! My ObiSolver as well as my ObiUpdater are children of my player, and are thus moved at the same time as the player itself. Here is a picture of the hierarchy[Image: pB1u2xJ.png]
For context, here, End1 and End2 are transforms that the player controls and the Obi Rope is attached to these transforms with ObiParticleAttachment. The "Player" object here is just a container, it is really just the two Ends that move in the world, which makes the ObiRope move.
I spawn my player in my bootstrap scene and deactivate it, and then when the level scene is loaded, I teleport the player to a spawn point, move him from the bootstrap scene to the level scene, and then activate it.

Code:
    public RopeController playerPrefab;
   
    public RopeController PlayerRopeController { get; private set; }

    protected override void Awake()
    {
        base.Awake();

        PlayerRopeController = Instantiate(playerPrefab);
        PlayerRopeController.gameObject.SetActive(false);
    }

    public void TeleportAndActivate(Scene scene, Vector3 position, Quaternion rotation)
    {
        SceneManager.MoveGameObjectToScene(PlayerRopeController.gameObject, scene);
        PlayerRopeController.transform.position = position;
        PlayerRopeController.transform.rotation = rotation;

        PlayerRopeController.gameObject.SetActive(true);
    }

When I do this, the player is successfully moved to the right scene, as well as the Solver and Updater. However, while the two "ends" (End1 and End2) seem fine, the ObiRope itself seems to detach from the ObiParticleAttachement transforms (aka End1 and End2) and fall through the floor.

I have found though, that if my Player prefab is saved inactive instead of deactivated after spawning, everything is fine when the Player is moved to the level scene. However I would like to be able to keep my Player prefab active in editor to prevent oversight when editing (for example forgetting to set it to inactive after making changes)

Thanks again in advance!
Reply
#4
Will try to reproduce this and get back to you. Attachments should definitely work even after reactivating the rope.
Reply
#5
I made a repro project and a package in Unity 2020.1.7f1 if you'd like:
Here is a Repro Package and a Repro Project

In any case, the simplest repro steps I have are:
  1. Create Obi Rope
  2. Rename the control points (don't know if this step is necessary at all)
  3. Assign it a Rope Blueprint
  4. Create 2 transforms as children of the Obi Solver and give them Obi Colliders
            (This could be the problem. When I move them outside the Obi Solver, the rope stays attached when I toggle the rope itself or the attachments targets)
  5. Add 2 ObiParticleAttachments to the ObiRope, set them dynamic and assign them the 2 previously created transforms
  6. Press Play
  7. Set the Obi Solver Inactive, and then reactivate it.
Result: the rope is detached from the 2 attachements and falls off

Here is a gif of what happens and an overview of the setup in a clean project: https://i.imgur.com/a7KrgEk.gifv

Good luck and thanks!
Reply
#6
(22-12-2020, 12:18 PM)josemendez Wrote: Will try to reproduce this and get back to you. Attachments should definitely work even after reactivating the rope.

Hi, any news on this?
Thanks
Reply
#7
Replace the file at /Obi/Scripts/Common/Utils/ObiParticleAttachment.cs with the one attached, that should fix the issue.

Let me know if the problem persists. cheers!


Attached Files
.cs   ObiParticleAttachment.cs (Size: 17.87 KB / Downloads: 4)
Reply
#8
(25-01-2021, 03:27 PM)josemendez Wrote: Replace the file at /Obi/Scripts/Common/Utils/ObiParticleAttachment.cs with the one attached, that should fix the issue.

Let me know if the problem persists. cheers!

Hey Jose!

I wanted to say that I thank you for your support, and I'm back with some results!

The new script did indeed work in making it so that the attachments persist through the toggling on/off of the solver that contains the rope or the rope itself!
One thing seems weird though, and I wouldn't know if it this is a by-product of the changes to the ObiParticleAttachment.

Here is a gif that shows in a first part how the rope stays attached when I toggled the solver or the rope itself, and in the second part it shows what happens when I toggle one of the attachment targets. There seems to be a sort of doubling of the rope, or something like that?

Would there be any way to fix this?

Thanks in advance
Reply
#9
(30-01-2021, 08:16 PM)KnotANumber Wrote: Hey Jose!

I wanted to say that I thank you for your support, and I'm back with some results!

The new script did indeed work in making it so that the attachments persist through the toggling on/off of the solver that contains the rope or the rope itself!
One thing seems weird though, and I wouldn't know if it this is a by-product of the changes to the ObiParticleAttachment.

Here is a gif that shows in a first part how the rope stays attached when I toggled the solver or the rope itself, and in the second part it shows what happens when I toggle one of the attachment targets. There seems to be a sort of doubling of the rope, or something like that?

Would there be any way to fix this?

Thanks in advance

Hi there!

Will try to reproduce and get back to you asap.
Reply
#10
Hi again,

Indeed this was caused by the previous fix. Comment out the

Code:
if (dirty)

line at the end of UpdateDynamicAttachment(). This is just a workaround that will rebuild the pin constraint every frame, since a proper fix turns out to be more involved and requires a few changes in the solver.

The next update will contain a proper fix for this bug. thanks for reporting it!
Reply