Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Runtime Rope Generation
#1
First off this all works fine if generated in editor beforehand. If I create a rope and hit play it works just fine with my procedurally generated Obi Colliders.

However if I generate my rope at runtime there seems to be no recognition of the Obi Colliders.

The way I have generated the ropes is basically like so, I pretty much copied the documentation from the website. What am I missing to get them to partake in the physics system?

Code:
    var blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
    blueprint.path.Clear();
    //for each point in the navmesh path generated
    blueprint.path.AddControlPoint(relativePosition, pointHandleIn, pointHandleOut, pointNormal, .1f, .1f, 1, 1, Color.white, i.ToString());
    
    blueprint.path.FlushEvents();
    blueprint.GenerateImmediate();
    var ropeRenderer = connectedWire.GetComponent<ObiRopeExtrudedRenderer>();
    var rope = g.GetComponent<ObiRope>();
    ropeRenderer.section = Resources.Load<ObiRopeSection>("DefaultRopeSection");
    rope.ropeBlueprint = ScriptableObject.Instantiate(blueprint);
    rope.transform.SetParent(solverParent.transform, true);

Thanks
Reply
#2
Hi,

You need to pass appropriate collision filters to your control points. right now you're just passing "1" as the filter, which may or may not generate collisions depending on the filters set on your colliders.

Check out "collision filtering" in the manual:
http://obi.virtualmethodstudio.com/manua...sions.html

Also check the AddControlPoint function in the API docs. You can either build your filters manually using bitwise operators, or use Obi's MakeFilter() helper function.

Filters are made of a mask and a category. The mask is the first parameter of the ObiUtils.MakeFilter() function. Just keep in mind the mask is a bit mask (just like Unity's layer masks), so you build it by simply or'ing together bits. For instance, to build a mask that collides with categories 1, 3, and 6:

Code:
int mask = (1 << 1) | (1 << 3) | (1 << 6);
int filter = ObiUtils.MakeFilter(mask, 0); // used category 0, could use any other.

If you want a filter that collides with everything:
Code:
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);

Note you need to be familiar with bitwise operators to understand this. If you're not sure what this means, look them up. There's many tutorials around dealing with bit manipulation (in C# as well as other languages), the above link to Unity's layer masks is a good starting point as they work just like Obi's filter masks.
Reply
#3
Ok thanks, I reverted my branch and stopped working with it for now but will try it in the future. I suggest you amend the tutorial on your website to include this information you've given me @

http://obi.virtualmethodstudio.com/manua...ctors.html
Reply
#4
Hi,
I just had the exact same problem this morning, so i had to thank you for this well-timed reply.
I did set the filter to one aswell, but it turns out it sets its category on 0 but its collider mask to collide with nothing.
this works better now, Thanks!
Reply