06-07-2023, 11:50 AM
(This post was last modified: 06-07-2023, 11:51 AM by josemendez.)
(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,