07-08-2024, 11:53 AM
(This post was last modified: 07-08-2024, 11:58 AM by josemendez.)
(07-08-2024, 10:45 AM)vrtraining Wrote: Its called from an event but eventually that is propagated from Update method. It works fine as long as I don't resize the rope. If I increase the rope length and call it then it crashes in Obi 7
I've tried with and without calling ChangeLength(), doesn't make any difference for me. This is the code I'm using, which is nearly identical to yours:
Code:
using UnityEngine;
using Obi;
public class ResetRope : MonoBehaviour
{
public float initialLength = 3;
public ObiRope rope;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.F))
Reset();
}
public void Reset()
{
rope.RemoveFromSolver();
rope.ClearState();
rope.AddToSolver();
rope.GetComponent<ObiRopeCursor>().ChangeLength(initialLength - rope.restLength);
}
}