14-04-2020, 05:53 PM
I'm wondering is it possible to move pin constraints around on their attached collider's local space.
I have the following code (adapted from one of your samples),
I want to later come back here and say 'move constraint 0'. The "SourcePosition" property here will always provide the correct desired position in world space.
I thought maybe I could do something like this, but nothing seems to happen when I call it:
Any ideas? Or maybe this is inadvisable?
I have the following code (adapted from one of your samples),
Code:
ObiConstraints<ObiPinConstraintsBatch> pinConstraints = m_ropeBlueprint.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
ObiPinConstraintsBatch batch = pinConstraints.batches[0];
batch.AddConstraint(0, m_parentCollider, m_parentCollider.transform.InverseTransformPoint(SourcePosition), Quaternion.identity);
batch.AddConstraint(m_ropeBlueprint.activeParticleCount - 1, hitCollider.GetComponent<ObiColliderBase>(),
hitCollider.transform.InverseTransformPoint(hitPosition), Quaternion.identity);
batch.activeConstraintCount = 2;
I want to later come back here and say 'move constraint 0'. The "SourcePosition" property here will always provide the correct desired position in world space.
I thought maybe I could do something like this, but nothing seems to happen when I call it:
Code:
private void SetStartConstraint()
{
ObiConstraints<ObiPinConstraintsBatch> pinConstraints = m_ropeBlueprint.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
ObiPinConstraintsBatch batch = pinConstraints.batches[0];
batch.offsets.SetVector3(0, m_parentCollider.transform.InverseTransformPoint(SourcePosition));
//batch.AddConstraint(0, m_collider, m_parentCollider.transform.InverseTransformPoint(SourcePosition), Quaternion.identity);
}
Any ideas? Or maybe this is inadvisable?