Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope not colliding with other ObiColliders
#1
Hello,

I am facing an issue when I generate a ObiRope in script which is used in RopeNet example (please see attached video)

Everything works fine but the generated rope does not collide with the Ground or anything else which has an ObiCollider. 

Normal rope when created in editor collides as expected with the ground. Is there something I'm missing in the settings? Please help.

Thanks,
Abhi

Code:
public void GenerateRope(Vector3 pointA, Vector3 pointB, ObiCollider start, ObiCollider end)
    {
        // Create a rope
        var ropeObject = new GameObject("solver", typeof(ObiRope), typeof(ObiRopeLineRenderer));
        var rope = ropeObject.GetComponent<ObiRope>();
        var ropeRenderer = ropeObject.GetComponent<ObiRopeLineRenderer>();
        rope.GetComponent<MeshRenderer>().material = material;
        rope.GetComponent<ObiPathSmoother>().decimation = 0.1f;
        ropeRenderer.uvScale = new Vector2(1, 5);

        // Setup a blueprint for the rope:
        var blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
        blueprint.resolution = blueprintResolution;
        blueprint.thickness = blueprintThickness;
        blueprint.pooledParticles = blueprintPooledParticles;

        // convert both points to the rope's local space:
        pointA = rope.transform.InverseTransformPoint(pointA);
        pointB = rope.transform.InverseTransformPoint(pointB);

        // Procedurally generate the rope path (a simple straight line):
        Vector3 direction = (pointB - pointA) * 0.25f;
        blueprint.path.Clear();
        blueprint.path.AddControlPoint(pointA, -direction, direction, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "A");
        blueprint.path.AddControlPoint(pointB, -direction, direction, Vector3.up, 0.1f, 0.1f, 1, 1, Color.white, "B");
        blueprint.path.FlushEvents();

        rope.ropeBlueprint = blueprint;

        rope.transform.parent = solver.transform;

        PinRope(rope, start, end, new Vector3(0, 0.5f, 0), -new Vector3(0, 0.5f, 0));
    }

    private void PinRope(ObiRope rope, ObiCollider bodyA, ObiCollider bodyB, Vector3 offsetA, Vector3 offsetB)
    {
        // Pin both ends of the rope (this enables two-way interaction between character and rope):
        var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
        pinConstraints.Clear();
        var batch = new ObiPinConstraintsBatch();
        batch.AddConstraint(rope.solverIndices[0], bodyA, offsetA, Quaternion.identity, 0, 999, float.PositiveInfinity);
        batch.AddConstraint(rope.solverIndices[rope.activeParticleCount - 1], bodyB, offsetB, Quaternion.identity, 0, 999, float.PositiveInfinity);
        batch.activeConstraintCount = 2;
        pinConstraints.AddBatch(batch);
    }
Reply


Messages In This Thread
Rope not colliding with other ObiColliders - by bubbbles - 08-01-2022, 06:41 AM