Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  how can i creat a chain at run time
#2
(29-07-2020, 02:03 AM)huahuapro Wrote: hi, I just buy the ObiRope, it's so cool. i'm useing your demo GrappingHook, i use it to my little demo. please see the video.



i can attch rope from player to a object, but the object is so wired, the physic seems not right when is attched to the rope. and you can see the second
time in my video the chain and the object is all good.but the second time i don't use run time generate。

and how can i change the rope to a chain?

i think is this code?

Code:
// 設置兩點的交互,rope對物體的影響在這裡設置:
        var pinConstraints = blueprint.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
        //var pinConstraints = blueprint.GetConstraintsByType(Oni.ConstraintType.Chain) as ObiConstraints<ObiPinConstraintsBatch>;
        var batch = pinConstraints.batches[0];
        batch.AddConstraint(0, character, transform.localPosition, Quaternion.identity);
        batch.AddConstraint(blueprint.activeParticleCount - 1, hookAttachment.collider.GetComponent<ObiColliderBase>(),
                                                          hookAttachment.collider.transform.InverseTransformPoint(hookAttachment.point), Quaternion.identity);
        batch.activeConstraintCount = 2;

sorry for my english, thanks.

By default, pin constraints constrain both position and orientation. You must set the orientation compliance to a higher than zero value if you want free rotation. Each batch has an "stiffnesses" array that contains 2 * constraintCount entries: the first entry is the positional compliance, and the second one the rotational compliance. So:

Code:
Code:
batch.stiffnesses[constraintIndex * 2 + 1] = 10000; // really high compliance value frees up rotation.

To create a "chain" instead of a rope, use a ObiRopeChainRenderer component, instead of a ObiRopeExtrudedRenderer. This does not affect rope physics, only the way it is rendered. See:
http://obi.virtualmethodstudio.com/tutor...modes.html
Reply


Messages In This Thread
RE: how can i creat a chain at run time - by josemendez - 29-07-2020, 07:29 AM