Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding attachments at runtime to a pre-existing instance of a rope in 5.X
#3
Thank you for your help--I would have replied sooner, but I didn't realize I didn't have email notifications enabled Triste


The information you provided was really valuable to me. However, I'm still not certain how to actually add a constraint to an actor entirely through code, especially given that I don't seem to see much documentation on the Obi API for 5.X. I noticed (by looking at the source code directly) that GetConstraintsByType is also a method on ObiActor...


Code:
 private bool hasConstraint = false;

 public void OnRopeCollision(ObiRope rope, int ropeIndex) {
   if (hasConstraint) {
     return;
   }

   hasConstraint = true;
   var pinConstraints =
       rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
   ObiPinConstraintsBatch batch = pinConstraints.GetFirstBatch();
   batch.AddConstraint(ropeIndex, _obiCollider, new Vector3(), Quaternion.identity);
   batch.activeConstraintCount++;
   _obiCollider.Phase = 1;
 }

Still no change in behavior, but it seems at least more correct.

Specifically, the arguments for the method are:
Code:
     ObiSolver.ParticleInActor pa = _solver.particleToActor[contact.particle];
     var rope = pa.actor as ObiRope;
     int ropeIndex = pa.indexInActor;
Reply


Messages In This Thread
RE: Adding attachments at runtime to a pre-existing instance of a rope in 5.X - by eliza - 11-05-2020, 05:48 AM