Obi Official Forum
Suggestion / Idea Problem with the Obi Solver Structure - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: General (https://obi.virtualmethodstudio.com/forum/forum-5.html)
+--- Thread: Suggestion / Idea Problem with the Obi Solver Structure (/thread-1491.html)

Pages: 1 2


RE: Problem with the Obi Solver Structure - josemendez - 22-11-2019

(22-11-2019, 03:56 PM)Bill Sansky Wrote: Let me clarify my use case:

I have only one ObiRope in my prefab, but all my ropes must interact with each other. However my rope is not the root object of my prefab, it has other objects that have a different role, all under one "cable" object that can be pooled.

https://drive.google.com/open?id=1ENJLRxpf_qacU0dObdVtUgsxl-LgNOZ4

That is why I need to check for all the parent transform since my ObiRope is not the root object

I get the point, it is useful to recursively check all transforms up here. Will make sure to cover this use case too.


RE: Problem with the Obi Solver Structure - Bill Sansky - 22-11-2019

Awesome!

Thanks a lot for your support and for taking the time to listen, it means a lot Sonrisa


RE: Problem with the Obi Solver Structure - josemendez - 22-11-2019

(22-11-2019, 04:31 PM)Bill Sansky Wrote: Awesome!

Thanks a lot for your support and for taking the time to listen, it means a lot Sonrisa

It's thanks to user feedback like yours that things move in the right direction, so thank you for discussing these issues with me! Sonrisa.


RE: Problem with the Obi Solver Structure - josemendez - 26-11-2019

Hi Bill,

I slightly modified the actor's Awake method, to support multiple actors in the prefab's hierarchy without any downsides. It is also slightly cleaner and concise. Here's the updated version:

Code:
protected void Awake()
        {
#if UNITY_EDITOR

            // Check if this script's GameObject is in a PrefabStage
            var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(gameObject);

            if (prefabStage != null)
            {
                // Only create a solver if there's not one up our hierarchy.
                if (GetComponentInParent<ObiSolver>() == null)
                {
                    // Add our own environment root and move it to the PrefabStage scene
                    var newParent = new GameObject("ObiSolver (Environment)", typeof(ObiSolver), typeof(ObiLateFixedUpdater));
                    newParent.GetComponent<ObiLateFixedUpdater>().solvers.Add(newParent.GetComponent<ObiSolver>());
                    UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(newParent, gameObject.scene);
                    transform.root.parent = newParent.transform;
                }
            }
#endif
        }



RE: Problem with the Obi Solver Structure - Bill Sansky - 26-11-2019

Awesome! Thanks a lot!