Yesterday, 04:30 PM
Hi!
I had to upgrade Obi Rope from version 3 to 7 because I bought Obi SoftBody as well, and unfortunately, they don't work on separate versions.
I’m not quite familiar with this version yet.
How can I generate a ropes that always has the same length?
Currently, it generates the rope based on the distance between the Start and End points, but I don’t want that. I tried using "controlPoints.Add(Vector3.down * ropeLength);" like in the old version but it's does not work anymore.
If i switch startp.position, endp.position to Vector3.zero, Vector3.one Then nothing happens when i create the rope.
This is the script I’m currently using, and it works well, but compared to the ExtendableGrapplingHook.cs, it seems quite incomplete.
Could it cause any issues that I’m not using a Coroutine or that "var batch = new ObiPinConstraintsBatch();" section?
Or could it be that the missing parts are exactly why my rope isn't generating properly when I use Vector3.zero, Vector3.one instead of my Transforms?
I know my questions are very basic but i didn't find a normal "Runtime Rope Generator" example.
Thank you in advance.
I had to upgrade Obi Rope from version 3 to 7 because I bought Obi SoftBody as well, and unfortunately, they don't work on separate versions.
I’m not quite familiar with this version yet.
How can I generate a ropes that always has the same length?
Currently, it generates the rope based on the distance between the Start and End points, but I don’t want that. I tried using "controlPoints.Add(Vector3.down * ropeLength);" like in the old version but it's does not work anymore.
Code:
public Transform startp;
public Transform endp;
public Material material;
private ObiRope rope;
public ObiSolver solver;
public ObiRopeBlueprint ropeBlueprint;
private ObiRopeCursor cursor;
public void createropeline()
{
solver = GameObject.Find("Obi Solver").GetComponent<ObiSolver>();
GameObject ropeObject = new GameObject("ObiRope");
ropeObject.transform.SetParent(solver.transform);
rope = ropeObject.AddComponent<ObiRope>();
var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
pinConstraints.Clear();
var ropeRenderer = ropeObject.AddComponent<ObiRopeLineRenderer>();
ropeRenderer.uvScale = new Vector2(1, 5);
ropeRenderer.material = material;
rope.bendConstraintsEnabled = false;
rope.stretchingScale = 0.5f;
rope.aerodynamicsEnabled = false;
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
ropeBlueprint.path.Clear();
ropeBlueprint.path.AddControlPoint(startp.position, Vector3.zero, Vector3.zero, Vector3.zero, 0.05f, 0.05f, 0.3f, filter, Color.white, "Start");
ropeBlueprint.path.AddControlPoint(endp.position, Vector3.zero, Vector3.zero, Vector3.zero, 0.05f, 0.05f, 0.3f, filter, Color.white, "End");
ropeBlueprint.path.FlushEvents();
rope.ropeBlueprint = ropeBlueprint;
AttachRopeEnds();
}
public void AttachRopeEnds()
{
if (rope == null || ropeBlueprint == null)
return;
var attachmentA = rope.gameObject.AddComponent<ObiParticleAttachment>();
attachmentA.target = startp;
attachmentA.particleGroup = ropeBlueprint.groups[0];
attachmentA.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
var attachmentB = rope.gameObject.AddComponent<ObiParticleAttachment>();
attachmentB.target = endp;
attachmentB.particleGroup = ropeBlueprint.groups[ropeBlueprint.groups.Count - 1];
attachmentB.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
}
If i switch startp.position, endp.position to Vector3.zero, Vector3.one Then nothing happens when i create the rope.
This is the script I’m currently using, and it works well, but compared to the ExtendableGrapplingHook.cs, it seems quite incomplete.
Could it cause any issues that I’m not using a Coroutine or that "var batch = new ObiPinConstraintsBatch();" section?
Or could it be that the missing parts are exactly why my rope isn't generating properly when I use Vector3.zero, Vector3.one instead of my Transforms?
I know my questions are very basic but i didn't find a normal "Runtime Rope Generator" example.
![Indeciso Indeciso](https://obi.virtualmethodstudio.com/forum/images/smilies/undecided.png)
Thank you in advance.
![Sonrisa Sonrisa](https://obi.virtualmethodstudio.com/forum/images/smilies/smile.png)