Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting Questions
#3
How can I update a rope after I change the material or the end.  If I am running a level, and I click on the initialize button, the rope will freeze.

If I use the code from the grappling hook, the rope ends, get pinned.  Sample code below.

I need to update the rope in runtime and have it keep settings.

#2) what is "avoid translating MeshColliders at runtime using their transform."  Do u have better description or screen shot?

#3) Is there an easy way in code to set phase?  I would like to set all of the particles to int X on a rope.


public ObiRope rope;
public ObiRope Rope = new ObiRope();
public ObiSolver Solver = new ObiSolver();
public Material ColorMat = new Material("");
public ObiCatmullRomCurve Curve = new ObiCatmullRomCurve();
public ObiRopeCursor Cursor = new ObiRopeCursor();

void MakeRope()
{
    if (Rope == null)
        Rope = gameObject.AddComponent<ObiRope>();

    if (Curve == null)
    {
        Curve = gameObject.AddComponent<ObiCatmullRomCurve>();
        Rope.ropePath = Curve;
    }
    if (Solver == null)
    {
        Solver = gameObject.AddComponent<ObiSolver>();
        Rope.Solver = Solver;
    }

    // Provide a solver and a curve:
    Rope.GetComponent<MeshRenderer>().material = ColorMat;

    //Configure rope and solver parameters:
    Rope.SectionThicknessScale = 0.10f;
    Rope.resolution = 1f;
    Rope.BendingConstraints.stiffness = 0.2f;
    Rope.UVScale = new Vector2(1, 5);
    Rope.NormalizeV = false;
    Rope.UVAnchor = 1;

    Rope.RestLength = 10;
    Solver.distanceConstraintParameters.iterations = 15;
    Solver.pinConstraintParameters.iterations = 15;
    Solver.bendingConstraintParameters.iterations = 1;

    //Add a cursor to change rope length:
    Cursor = Rope.gameObject.AddComponent<ObiRopeCursor>();
    Cursor.rope = Rope;
    Cursor.normalizedCoord = 0;
    Cursor.direction = true;
}
 
public void UpdateRope()
{
    StartCoroutine(CreateRope());
}
private IEnumerator CreateRope()
{
    yield return rope.GeneratePhysicRepresentationForMesh();
}
Reply


Messages In This Thread
Scripting Questions - by Parker - 13-09-2017, 05:11 AM
RE: Scripting Questions - by josemendez - 13-09-2017, 10:01 AM
RE: Scripting Questions - by Parker - 15-09-2017, 05:36 AM
RE: Scripting Questions - by josemendez - 15-09-2017, 08:14 AM
RE: Scripting Questions - by Parker - 15-09-2017, 01:34 PM
RE: Scripting Questions - by Parker - 16-09-2017, 07:25 PM
RE: Scripting Questions - by Parker - 16-09-2017, 10:23 PM