(17-08-2021, 09:08 AM)josemendez Wrote: You need to set custom restPositions every frame, since using a cursor the extend/retract the rope re-calculates all restPositions.Ahh, I see. Figured it out. Here's a generic solution for anyone who wants the same behavior;
Code:
using Obi;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class ObiStitchSelfCollisionDisabler : MonoBehaviour
{
public bool DisableSelfCollisionOnStitchedParticles = true;
[SerializeField]
private ObiStitcher ObiStitcher;
private List<ObiStitcher.Stitch> stitches;
private void Start()
{
stitches = ObiStitcher.Stitches.ToList();
}
private void FixedUpdate()
{
foreach (ObiStitcher.Stitch stitch in stitches)
{
if (DisableSelfCollisionOnStitchedParticles)
{
ObiStitcher.Actor1.solver.restPositions[stitch.particleIndex1] = new Vector3(0, 0, 0);
ObiStitcher.Actor2.solver.restPositions[stitch.particleIndex2] = new Vector3(0, 0, 0);
}
}
}
}
Thanks a lot Josemendez!