Latest Threads |
Scripting rod forces
Forum: Obi Rope
Last Post: josemendez
Yesterday, 03:28 PM
» Replies: 24
» Views: 2,328
|
Burst error causing crash...
Forum: Obi Rope
Last Post: josemendez
Yesterday, 07:03 AM
» Replies: 1
» Views: 88
|
Controlling speed of emit...
Forum: Obi Fluid
Last Post: josemendez
06-09-2025, 06:29 AM
» Replies: 1
» Views: 304
|
Looks nice on editor but ...
Forum: Obi Fluid
Last Post: josemendez
04-09-2025, 07:20 AM
» Replies: 3
» Views: 597
|
How to Shorten or Scale t...
Forum: Obi Rope
Last Post: josemendez
02-09-2025, 09:53 AM
» Replies: 5
» Views: 683
|
The Limitation of Using O...
Forum: Obi Rope
Last Post: josemendez
01-09-2025, 10:30 PM
» Replies: 1
» Views: 442
|
Bug Where a Straight Segm...
Forum: Obi Rope
Last Post: josemendez
01-09-2025, 08:46 PM
» Replies: 1
» Views: 440
|
Having an issue with obi ...
Forum: Obi Rope
Last Post: Ben_bionic
29-08-2025, 04:23 PM
» Replies: 4
» Views: 900
|
Non-uniform particle dist...
Forum: Obi Rope
Last Post: chenji
29-08-2025, 09:05 AM
» Replies: 4
» Views: 776
|
Is it possible to impleme...
Forum: Obi Rope
Last Post: chenji
27-08-2025, 10:13 AM
» Replies: 2
» Views: 699
|
|
|
Clear singletons |
Posted by: Jawsarn - 10-01-2025, 10:27 PM - Forum: General
- Replies (1)
|
 |
It would be very neat to clear the static variables to support disabled domain reloading.
As of now from time to time it just breaks and ObiColliderWorld is null and no ropes work after you enter playmode before you do a new domain reload.
|
|
|
Closed loop rope, move particles to stretch it |
Posted by: alicecatalano - 07-01-2025, 12:55 PM - Forum: Obi Rope
- Replies (3)
|
 |
Good morning,
i am creating a simulation where everytime the game gets loaded there is an example shape around some nails an elastic has to reach.
the elastic is represented by a closed loop obirope.
in the start method i call a function that sets the elastic global position based on the shape. Now i woul dlike to actually move 2 or 3 particles to create the shape and hook the nails i need to
private void Start()
{
repetition = GameManager.Instance.GetCurrentRepetition();
Debug.Log("repetition is : " + repetition);
SetNailsAndElastic(repetition);
}
private void SetNailsAndElastic(int repetitionNumber)
{
GameObject[] allNails = GameObject.FindGameObjectsWithTag("Nail");
foreach (GameObject nail in allNails)
{
nail.GetComponent<Renderer>().material = defaultMaterial;
}
switch (repetitionNumber)
{
case 1:
HighlightNails(new string[] { "nail_1_r1", "nail_c_r1" });
Debug.Log("in rep1");
elastic.transform.position = new Vector3(-2.17000008f, 0.810000002f, -10.4899998f);
elastic.TeleportParticle(82, new Vector3(1, 3, 5));
//elastic.blueprint.positions[82] = new Vector3(1, 3, 5);
}
this is a small snippet of my code, and this is what i try to do to move that specific particle for example.
The particle doesn't move though, even if the elastic takes the right position i wrote there
do you have any advice??
|
|
|
ObiNativeList memory leak? |
Posted by: CptnFabulous - 05-01-2025, 09:46 AM - Forum: Obi Cloth
- Replies (1)
|
 |
I'm using Obi Cloth 7.0.3, in Unity version 2022.3.51f1.
We have a system that automatically generates meshes and turns them into cloths. We've been troubleshooting issues with inconsistent cloth behaviour, and noticed some leaks. The messages don't seem to specify if they're memory leaks, handle leaks or some other kind of leak.
One of the leak logs. They're all related to line 256 of ObiNativeList, and all occur as a consequence of the solver running Initialize() as part of InsertBufferedActor():
Code: Found 1 leak(s) from callstack:
0x000002c3843952e3 (Mono JIT Code) UnityEngine.GraphicsBuffer:.ctor (UnityEngine.GraphicsBuffer/Target,int,int)
0x000002c6ab4f44a3 (Mono JIT Code) Obi.ObiNativeList`1<Obi.ForceZone>:AsComputeBuffer<Obi.ForceZone> (int,UnityEngine.GraphicsBuffer/Target) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs:256)
0x000002c6ab4f43cb (Mono JIT Code) Obi.ObiNativeList`1<Obi.ForceZone>:SafeAsComputeBuffer<Obi.ForceZone> (UnityEngine.GraphicsBuffer/Target) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs:239)
0x000002c6ab4f431b (Mono JIT Code) Obi.ComputeColliderWorld:SetForceZones (Obi.ObiNativeForceZoneList) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Backends/Compute/Collisions/ComputeColliderWorld.cs:239)
0x000002c383c08eea (Mono JIT Code) Obi.ObiColliderWorld:UpdateWorld (single) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:600)
0x000002c6ab4e105b (Mono JIT Code) Obi.ObiSolver:Initialize () (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1267)
0x000002c6ab4e036b (Mono JIT Code) Obi.ObiSolver:InsertBufferedActor (Obi.ObiActor) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1971)
0x000002c383c1c343 (Mono JIT Code) Obi.ObiSolver:StartSimulation (single,int) (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1611)
0x000002c383c1b8b3 (Mono JIT Code) Obi.ObiSolver:LateUpdate () (at C:/Users/marcu/Documents/Bitbucket/Standalone stencil test/Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1171)
0x000002c384ad7ae8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ff8fe104c2e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ff8fe03d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ff8fe03d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff616b87104 (Unity) scripting_method_invoke
0x00007ff616b64d14 (Unity) ScriptingInvocation::Invoke
0x00007ff616b4c4a4 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff616b4c5ca (Unity) MonoBehaviour::CallUpdateMethod
0x00007ff6165de82b (Unity) BaseBehaviourManager::CommonUpdate<LateBehaviourManager>
0x00007ff6165e59fa (Unity) LateBehaviourManager::Update
I know we haven't altered any of this code. The leaks don't occur the first time I enter Play Mode, but do occur after exiting and re-entering Play Mode. It might be a bug with Obi Cloth itself, but the more likely explanation is I'm creating some data that's not being properly disposed of after exiting Play Mode. Then on the next play, the cloth simulation looks for data that has since been destroyed, which causes both the leakage and wonky cloth physics.
What data is created as part of Obi Cloth's standard functionality, that needs to be manually disposed of by the user? I updated the Obi Cloth version to 7.0.3 from 6.5.4, so I imagine there's some part of our code that would have worked fine with the previous version.
Thanks!
|
|
|
Broken scripts with update 6 -> 7 |
Posted by: hariedo - 21-12-2024, 10:35 AM - Forum: Obi Rope
- Replies (11)
|
 |
Had some issues with the update from Obi Rope 6 -> 7 in a project that used Obi Rope 6. Luckily it's a scratch project.
1. I tried upgrading on top of the old version but saw script errors so I removed all Obi files and installed fresh instead. Of course, I have scripts and prefabs that depend on the older Obi files, so all of those break in the process of installation. Even after the other issues were patched below, my existing code runs into Index Of Of Range errors on trying to load my existing rope blueprints, so now I have to see if it's a code issue or a blueprint schema change issue. [Edit: I see the forum update guide says you have to regen blueprints. I'm creating them from code, see below.]
2. The demo scenes use a resource script called FPSDisplay. It does not use a namespace, so it conflicted with another script I already had called FPSDisplay. This caused compilation errors and breaks the script references in scenes that used either one (my existing scenes, as well as your demo scenes.) Even after I added a namespace to my existing FPSDisplay, the script references were broken, so I had to add a namespace to your file and re-add it to the demo scene objects. I thought Unity demanded all assets used namespaces to avoid this sort of conflict. [Edit: Similar breakage on SlowmoToggler which does not have a namespace (I have no such script but your demo scene had a broken link to it and Unity couldn't find it until I added one).]
3. Many of your demo scenes use a built-in diffuse material for many objects. Please define your own material for these objects, so that when I update all materials to URP these objects don't remain pink.
4. There is no longer a type for ObiFixedUpdater. I had a script that expected this type to force a regeneration of ropes (as I would deactivate and reactivate ropes in proximity to the player). The CHANGELOG says all ObiUpdater types have been removed. No guidance on what to do about scripts that referenced them.
Here is the code I'm trying to migrate. It generates new blueprints on the fly during Start.
My prefab has four of these, and each one is spitting out Null Reference errors in your DrawGizmos in Edit mode.
Quote:NullReferenceException: Object reference not set to an instance of an object
Obi.ObiRopeCursorEditor.DrawGizmos (Obi.ObiRopeCursor cursor, UnityEditor.GizmoType gizmoType) (at Assets/Plugins/Obi/Editor/RopeAndRod/ObiRopeCursorEditor.cs:75)
Once I try running, I get Index Out Of Bounds errors in your ObiActor.LoadBlueprintParticles, when I provide the generated blueprint to ObiRope. One error per rope, with different starting index numbers.
Quote:IndexOutOfRangeException: Writing to index 0 is out of range of '0' Capacity.
Obi.ObiNativeList`1[T].set_Item (System.Int32 index, T value) (at Assets/Plugins/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs:98)
Obi.ObiActor.LoadBlueprintParticles (Obi.ObiActorBlueprint bp) (at Assets/Plugins/Obi/Scripts/Common/Actors/ObiActor.cs:995)
Obi.ObiActor.LoadBlueprint (Obi.ObiSolver solver) (at Assets/Plugins/Obi/Scripts/Common/Actors/ObiActor.cs:1161)
Obi.ObiRope.LoadBlueprint (Obi.ObiSolver solver) (at Assets/Plugins/Obi/Scripts/RopeAndRod/Actors/ObiRope.cs:187)
Screenplay.TightRope.Generate () (at Assets/__SHARED__/Scripts/For/Obi/TightRope.cs:109)
Screenplay.TightRope.Start () (at Assets/__SHARED__/Scripts/For/Obi/TightRope.cs:45)
Code: // TightRope.cs
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
using Obi;
namespace Screenplay
{
//
// Combines the logic of Obi's RopeBetweenTwoPoints and ObiRopeReel
// to form a simulated rope between any two transforms, with managed slack.
//
public class TightRope: MonoBehaviour, ICraneRope
{
public ObiSolver solver;
public ObiRopeCursor cursor;
public ObiRope rope;
public Transform start;
public ObiParticleAttachment startAttachment;
public Transform end;
public ObiParticleAttachment endAttachment;
public const float MINIMUM_SLACK = 0.0f;
public const float MAXIMUM_SLACK = 1.0f;
[Range(MINIMUM_SLACK, MAXIMUM_SLACK)]
[Tooltip("How much additional length beyond distance from start to end")]
public float slack = 0.1f;
[Tooltip("How much change in length required to recalculate rope")]
public float deltaLength = 0.05f;
public float cursorMu = 0.5f;
public float sourceMu = 0.95f;
private float priorLength = float.NegativeInfinity;
void Start()
{
Generate();
// the rope actor must be a child under a solver to start the simulation
transform.SetParent(solver.transform);
}
// ICraneRope
public float GetLength()
{
if (priorLength > 0f)
return priorLength;
return IdealLength();
}
public float GetMaximumSlack() => MAXIMUM_SLACK;
private float IdealLength()
{
float taut = start.Distance(end);
if (slack < MINIMUM_SLACK)
slack = MINIMUM_SLACK;
return taut + slack;
}
public void Generate()
{
if (start == null || end == null)
return;
// Adjust our transform:
transform.position = start.position;
transform.rotation = start.rotation;
// Calculate control point positions and tangent vector:
Vector3 startPositionLS = transform.InverseTransformPoint(start.position);
Vector3 endPositionLS = transform.InverseTransformPoint(end.position);
Vector3 tangentLS = (endPositionLS - startPositionLS).normalized;
Vector3 normalLS = start.right;
// Add rope actor / renderer / attachment components:
rope = gameObject.GetComponent<ObiRope>();
rope.ropeBlueprint = null;
// Create the blueprint:
ObiRopeBlueprint clone;
clone = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
clone.resolution = 0.5f;
// Build the rope path:
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
clone.path.AddControlPoint(
startPositionLS, -tangentLS, tangentLS, normalLS,
0.1f, 0.1f, 1, filter, Color.white, "start");
clone.path.AddControlPoint(
endPositionLS, -tangentLS, tangentLS, normalLS,
0.1f, 0.1f, 1, filter, Color.white, "end");
clone.path.FlushEvents();
// Generate particles/constraints:
clone.GenerateImmediate();
// Set the blueprint:
rope.ropeBlueprint = clone;
rope.LoadBlueprint(solver);
cursor = gameObject.GetComponent<ObiRopeCursor>();
// Attach both ends:
startAttachment.target = start;
startAttachment.particleGroup = clone.groups[0];
endAttachment.target = end;
endAttachment.particleGroup = clone.groups[1];
}
// Update is called once per frame
void Update()
{
// get ideal rest length:
float restLength = IdealLength();
// if we haven't changed sufficiently, don't disturb it
if (Mathf.Abs(restLength - priorLength) < deltaLength)
return;
cursor.cursorMu = cursorMu;
cursor.sourceMu = sourceMu;
cursor.UpdateCursor();
// set the new rest length:
cursor.ChangeLength(restLength);
priorLength = restLength;
}
}
}
|
|
|
Null Reference, actor not loading |
Posted by: alicecatalano - 13-12-2024, 12:19 PM - Forum: Obi Rope
- Replies (1)
|
 |
Good morning,
I created a code to grasp an obiRope. It is not the first time i use it and untill now it worked fine, I have anotehr simulation that uses the same logic and I have no issues.
Now when the simulation starts the obiActor is not loaded in the script, even if i associated the code to it or passed it as a reference.
The grasping works but badly, and I think it is because of this issue.
the code:
```
using UnityEngine;
using Obi;
using System.Collections.Generic;
[RequireComponent(typeof(ObiActor))]
public class DistanceAnchor : MonoBehaviour
{
public ObiActor actor;
public ObiParticleAttachment attachment;
public Transform anchor;
public float anchorRadius = 0.5f;
private ForcepsControl forcepsControl;
private int groupIndex;
private bool isGrasping;
public bool IsGrasping
{
get { return isGrasping; }
}
void Awake()
{
actor = GetComponent<ObiActor>();
forcepsControl = FindObjectOfType<ForcepsControl>();
if (forcepsControl != null)
{
forcepsControl.OnRestPositionReached += CheckAndAnchorParticles;
forcepsControl.OnReleasePositionReached += Release;
}
}
void CheckAndAnchorParticles()
{
if (!actor.isLoaded)
{
Debug.LogError("Actor is not loaded");
return;
}
for (int i = 0; i < actor.solverIndices.count; ++i)
{
int solverIndex = actor.solverIndices[i];
float distance = Vector3.Distance(actor.GetParticlePosition(solverIndex), anchor.position);
Debug.Log($"Distance to Anchor: {distance}, Grasping State: {isGrasping}");
if (distance < anchorRadius && !isGrasping)
{
Grasp(actor, i);
}
}
}
private void Grasp(ObiActor actor, int index)
{
if (attachment != null)
{
Destroy(attachment);
}
attachment = actor.gameObject.AddComponent<ObiParticleAttachment>();
attachment.target = anchor; // Attach to the anchor
attachment.particleGroup = actor.blueprint.AppendNewParticleGroup("GraspedParticles");
groupIndex = actor.blueprint.groups.Count - 1; // Ensure it's the last added group
attachment.particleGroup.particleIndices = new List<int> { index };
attachment.compliance = 0;
attachment.attachmentType = ObiParticleAttachment.AttachmentType.Static;
isGrasping = true;
actor.solver.RemoveActor(actor); // Refresh the actor in the solver
actor.solver.AddActor(actor);
}
private void Release()
{
if (attachment != null)
{
Destroy(attachment);
actor.blueprint.RemoveParticleGroupAt(groupIndex);
actor.solver.RemoveActor(actor); // Refresh the actor in the solver
actor.solver.AddActor(actor);
isGrasping = false;
}
}
void OnDestroy()
{
if (forcepsControl != null)
{
forcepsControl.OnRestPositionReached -= CheckAndAnchorParticles;
forcepsControl.OnReleasePositionReached -= Release;
}
// Ensure to release any grasped particles
Release();
// Additional cleanup if needed
if (attachment != null)
{
Destroy(attachment);
attachment = null;
}
}
}
```
the error:
```
Actor is not loaded
UnityEngine.Debug:LogError (object)
DistanceAnchor:CheckAndAnchorParticles () (at Assets/Scripts/DistanceAnchor.cs:39)
ForcepsControl:UpdateThimbleRotation () (at Assets/Scripts/ForcepsControl.cs:70)
ForcepsControl:Update () (at Assets/Scripts/ForcepsControl.cs:51)
NullReferenceException: Object reference not set to an instance of an object
DistanceAnchor.CheckAndAnchorParticles () (at Assets/Scripts/DistanceAnchor.cs:43)
ForcepsControl.Update () (at Assets/Scripts/ForcepsControl.cs:48)
```
|
|
|
Changing extruded renderer's material runtime |
Posted by: aderae - 10-12-2024, 05:04 PM - Forum: Obi Rope
- Replies (2)
|
 |
Hello,
I have a logic where I need to change the ropes material during runtime. I tried setting obiRopeExtrudedRenderer.material = new Material(copyFrom); it looks like the material is changed in the component itself but it doesn't effect the renderer. I assume this is cached on start. Is there a way to do this?
Thanks
|
|
|
|