(12-08-2021, 02:16 PM)josemendez Wrote: Hi there,Simple rope w ~200 particles. No curser used. Two particle attachments, one in each end. Created from a blueprint made of 4 points on the curve (two start/end, two in the middle). All constraints default, except self and surface based collision turned on. Using the custom updater we discussed earlier (that I need for networking), but currently testing without networking;
The code looks fine. Tested it myself in an empty project and it works correctly too. Can you give more details about your setup?
Code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace Obi
{
/// <summary>
/// Updater class that will perform simulation during FixedUpdate(). This is the most physically correct updater,
/// and the one to be used in most cases. Also allows to perform substepping, greatly improving convergence.
[AddComponentMenu("Physics/Obi/Obi Custom Fixed Updater", 801)]
[ExecuteInEditMode]
public class ObiCustomFixedUpdater : ObiUpdater
{
/// <summary>
/// Each FixedUpdate() call will be divided into several substeps. Performing more substeps will greatly improve the accuracy/convergence speed of the simulation.
/// Increasing the amount of substeps is more effective than increasing the amount of constraint iterations.
/// </summary>
[Tooltip("Amount of substeps performed per FixedUpdate. Increasing the amount of substeps greatly improves accuracy and convergence speed.")]
public int substeps = 4;
public bool solve = true;
private float accumulatedTime;
private void OnValidate()
{
substeps = Mathf.Max(1, substeps);
}
private void Awake()
{
accumulatedTime = 0;
}
private void OnDisable()
{
Physics.autoSimulation = false;
}
private void FixedUpdate()
{
if (solve)
{
ObiProfiler.EnableProfiler();
BeginStep(Time.fixedDeltaTime);
float substepDelta = Time.fixedDeltaTime / (float)substeps;
// Divide the step into multiple smaller substeps:
for (int i = 0; i < substeps; ++i)
Substep(Time.fixedDeltaTime, substepDelta, substeps - i);
EndStep(substepDelta);
ObiProfiler.DisableProfiler();
accumulatedTime -= Time.fixedDeltaTime;
}
}
private void Update()
{
ObiProfiler.EnableProfiler();
Interpolate(Time.fixedDeltaTime, accumulatedTime);
ObiProfiler.DisableProfiler();
if (solve)
accumulatedTime += Time.deltaTime;
}
}
}
Edit; I noticed the further down the rope i test colission, the bigger the indexing error (in the photo its a few particles, but later down the rope its more than 20 indecies off);
Edit 2:
Just made a new scene in which it works perfectly - I tried with the same custom updater and the same rope blueprint - still works.
Then tried recreating the rope with a new rope component and solver in the original scene, and the issue still persists.
The only difference is the original scene has a bunch of obi colliders everywhere and some spherical force zones.
Edit 3:
Just redid the whole rope again and now it works. Have no idea where this indexing error came from.
The old one is still broken, and everything looks to be identical component wise;