28-03-2025, 04:42 PM
(This post was last modified: 28-03-2025, 06:55 PM by anthony_dev.)
(27-03-2025, 09:11 PM)josemendez Wrote: Hi,Hello,
Your code won’t work if any actor in the solver uses surface collisions. The reason is it assumes every simplex consists of a single particle, which may not be true in the general case. For instance, if all ropes in the solver use surface collisions, all simplices are tuples of 2 particles so your code will likely access indices belonging to the first rope only.
See the manual for example code snippets that show you how to access both actors involved in a contact:
https://obi.virtualmethodstudio.com/manu...sions.html
let me know if you need further help,
Kind regards
I have a question. If I make my ropes non-surface collision based, I still have this issue, why may this be?
I have my rope.surfacecollisions set to false, yet I still can't access to the second part of my code, which for now is just a simple debug.log function.
Here is how I create my rope in the function:
Code:
public ObiRope CreateRopeProcedurally(Transform parent, ObiCollider[] controlPoints, int index = 0)
{
var ropeObject = new GameObject($"Rope_{index}");
ropeObject.transform.parent = solver.transform;
//Create the rope initially
var rope = ropeObject.AddComponent<ObiRope>();
var blueprint = CreateBlueprint(parent, controlPoints, index ,out var length);
rope.ropeBlueprint = blueprint;
rope.surfaceCollisions = false;
rope.collisionMaterial = collisionMaterial;
var ropeRenderer = ropeObject.AddComponent<ObiRopeExtrudedRenderer>();
ropeRenderer.material = ropeMaterial;
ropeRenderer.section = ropeSection;
var smoother = rope.GetComponent<ObiPathSmoother>();
smoother.decimation = 0.1f;
smoother.smoothing = 1;
ropeRenderer.thicknessScale = (5f/ropeThickness) * 1.5f ;
ropeRenderer.uvScale = new Vector2(1, 2*length/3f);
var ropeReel = ropeObject.AddComponent<ObiRopeReel>();
ropeReel.outThreshold = 0.08f;
ropeReel.inThreshold = 0.05f;
rope.selfCollisions = true;
ropeReel.outSpeed = 6f;
ropeReel.inSpeed = 4f;
ropeReel.maxLength = Mathf.Max(1f, length/3f);
rope.maxBending = 0.5f;
rope.bendCompliance = 1f;
rope.stretchingScale = 3f;
var cursor = ropeObject.GetComponent<ObiRopeCursor>();
cursor.cursorMu = 0.05f;
cursor.sourceMu = 0.1f;
return rope;
}
You can see my variables and rope creation process here
I will be honest, I copied some components from sample scenes without truly understanding them, but this should work, right?
I set my Solver into interpolate mode and made surface collision iterations set to 1.