Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Resetting Rope causing Error
#10
Just realized there's an issue with both the above code and yours (in both Obi 6 and 7): it's not waiting for the rope to be actually loaded by the solver. So when called several times in a row the rest length may not be the length reflected in the blueprint, but the previous length of the rope. Won't cause any runtime errors, but the resulting length of the rope may not be correct.

Simply waiting for the rope to be loaded before changing its length fixes this:

Code:
using UnityEngine;
using Obi;
using System.Collections;

public class ResetRope : MonoBehaviour
{
    public float initialLength = 3;
    public ObiRope rope;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
            StartCoroutine(Reset());
    }

    public IEnumerator Reset()
    {
        rope.RemoveFromSolver();
        rope.ClearState();
        rope.AddToSolver();

        while (!rope.isLoaded)
            yield return new WaitForEndOfFrame();

        rope.GetComponent<ObiRopeCursor>().ChangeLength(initialLength - rope.restLength);
    }
}
Reply


Messages In This Thread
Resetting Rope causing Error - by vrtraining - 06-08-2024, 06:33 PM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 07:13 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 08:06 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 08:47 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 09:38 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 09:40 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 10:20 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 10:45 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 11:53 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 12:15 PM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 12:50 PM