Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  When the Obi Rope is tensioned
#5
(06-07-2023, 10:25 AM)josemendez Wrote: Ok, where during the update cycle are you doing this? Update, FixedUpdate, one of the solver callbacks...? You'd typically want to set these values in the solver's OnEndStep callback. Copying them at any other time may lead to the solver modifying these positions as part of its normal simulation cycle. The idea is that you want both solvers to have finished a simulation step, and copy their particle values before rendering takes place.

Also, make sure to copy previousPositions array and startPositions arrays. These are used to derive velocities and perform interpolation, respectively.


Unless you're explicitly writing custom data in ExternalForces and ExternalTorques, these values will always be zero. As the name implies, they're "external" to the simulation.

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());
    }
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 EunBhin Park - 06-07-2023, 10:31 AM
RE: When the Obi Rope is tensioned - by fevzi - 27-09-2023, 05:17 PM