Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ObiColliders and Procedural Load
#4
(01-02-2018, 08:23 PM)jonworks Wrote: In response, the suggestion to add another component to every collider that ever exists in my scene won't work for me and I'll have to think of something else. I can accept this and keep a favorable impression of this asset because mine is not a typical use case.

But to expand on my side note, I'm finding it extremely challenging to get Obi Rope to work at all. It would be easy to dismiss my troubles by saying that Obi exposes a lot of options making it more flexible but harder to configure. However, the users who require a robust product also need to implement it in a "real" way - IE doing it procedurally instead of using the amateur approach of setting up a prefabricated scene for every "level" and making players wait for loading time every time they walk through a door. Unless you're making the eighty billionth Mario clone, that just doesn't work for most people anymore. 

Now far be it from me to ask you to write my code for me, but I've read through every forum post and the entire Tutorials section and it's left me more confused than when I started. Everything is organized requiring the user to understand the entire Obi system instead of just what they're using, and there are constant references to "solver's ObiColliderGroup" which I don't even think applies anymore, and the Creating a pendulum video doesn't even mention ObiColliders. Everything in those resources assumes a static game world that is not loaded in real time. I've tried copying how ObiRopeHelper.cs works three times from scratch. Everything I do trying to figure it out results in some bizarre and unpredictable behavior making me think my entire methodology is wrong, which wouldn't surprise me at all since I've been completely guessing my way through it.

There are only a handful of functions needed to make rope work in a procedural environment, and I know a huge number of users would appreciate guidance in this area:

public class MyRope { //NOT a monobehavior
        private ObiRope rope;

       
        /// <summary>
        /// Creates a straight rope anchored to a transform at the top.
        /// Transform may or may not move around and may or may not have a rigidbody.
        /// When you call this the rope will appear in the scene and immediately interact with gravity and objects with ObiColliders.
        /// Called from anywhere (main thread only)
        /// Called when there is an empty scene (aside from passed transform) with nothing loaded and no prefabs available.
        /// </summary>
        public void make_rope(Transform anchored_to, Vector3 attachment_point_offset, float rope_length) { 
            //WHAT GOES HERE???

            [i]//
rope = ????
[/i]

        }

        /// <summary>
        /// make_rope and add_pendulum may be called on the same frame.
        /// Just adds a pendulum to the rope on the un-anchored end.
        /// </summary>
        public void add_pendulum(ObiRigidbody pendulum, Vector3 attachment_point_offset) {
            //WHAT GOES HERE???
        }

        /// <summary>
        /// remove_pendulum and add_pendulum may be called on the same frame.
        /// </summary>
        public void remove_pendulum() {
            //WHAT GOES HERE???
        }

        /// <summary>
        /// Like extending or retracting a winch.
        /// May need to include changes to the iteration count, 
        /// tether setup, or rope weight to prevent rope stretching depending on length and attached mass.
        /// </summary>
        public void change_rope_length(float change_amount) {
            //WHAT GOES HERE???
        }
    }


I'm getting so frustrated trying to make this work that I've considered leaving a negative review - something I've never done after downloading over two dozen assets - and I probably would have already done so if not for the reasonable support response time with intelligent answers. I'm sure you can fill in the blanks and test within a couple of hours since you understand the product so well, and if you can't then it should only underscore the importance of this code sample. I made it extremely generic on purpose so it would benefit the largest amount of users; it doesn't suit my case perfectly but would tell me what I need to know to figure it out.

Thanks,

Jon

Hi Jon,

There's a sample script included in the Obi/Scripts/Utils/ folder called "ObiRopeHelper.cs" that creates a rope at runtime from scratch. I know you mention you've been trying to follow it, but that's all there is to it really. Fixing the rope at one of its ends is just a matter of setting the first particle's inverse mass to zero using the Get/Set methods for particle properties (see http://obi.virtualmethodstudio.com/tutor...icles.html). ObiRopeHelper fixes both ends instead of just one, though.

The steps to follow when doing this programmatically are pretty much the same ones you do in the editor manually (Obi has been designed primarily with the goal to be able to create everything at runtime. Then, editor classes wrap this functionality and expose it trough the editor's UI):

- Create a ObiSolver, a ObiRope, a rope section and a one of the curve path components (we use ObiCatmullRomCurve in the sample script).
- Set the rope up: assign the solver, the path, and the section references.
- Add control points to the curve, to create any initial shape you want for the rope.
- Call GeneratePhysicRepresentationForMesh() (keep in mind that it is a coroutine).
- Call AddToSolver() on the rope.

Changing rope length can be accomplished trough the use of the ObiRopeCursor component. Just add this component to your rope and call ChangeLength(newLength). There's an example of this in Obi/SampleScenes/Crane. Should be pretty straightforward to use.

I'll whip a complete example script for you tomorrow.

cheers,
Reply


Messages In This Thread
ObiColliders and Procedural Load - by jonworks - 18-01-2018, 07:03 AM
RE: ObiColliders and Procedural Load - by josemendez - 01-02-2018, 09:00 PM