Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  When the Obi Rope is tensioned
#6
(06-07-2023, 10:31 AM)EunBhin Park Wrote: The source code is contained in a coroutine. It is initially called from Start() and repeats every 0.1 seconds using recursion.

private void Start()
    {
        if (isReceive)
        {
            StartCoroutine(Co_WaitUpdate());
        }
    }

private IEnumerator Co_WaitUpdate()
    {
        yield return new WaitForSeconds(0.1f);
        for (int i = 0; i < actor.solverIndices.Length; ++i)
        {
            rope.solver.positions[actor.solverIndices[i]] = otherRope.solver.positions[actor.solverIndices[i]];
            rope.solver.velocities[actor.solverIndices[i]] = otherRope.solver.velocities[actor.solverIndices[i]];
        }
        StartCoroutine(Co_WaitUpdate());
    }

Updating every 0.1 seconds without any regard for the physics timestep won't work. Moreover, coroutines are updated outside the normal physics loop in Unity.

Use the solver's callbacks to do this, as suggested.

kind regards,
Reply


Messages In This Thread
When the Obi Rope is tensioned - by EunBhin Park - 06-07-2023, 08:45 AM
RE: When the Obi Rope is tensioned - by josemendez - 06-07-2023, 11:50 AM
RE: When the Obi Rope is tensioned - by fevzi - 27-09-2023, 05:17 PM