Latest Threads |
Broken scripts with updat...
Forum: Obi Rope
Last Post: hariedo
11 hours ago
» Replies: 2
» Views: 85
|
Garment explodes on Andro...
Forum: Obi Cloth
Last Post: CptnFabulous
19-12-2024, 07:16 AM
» Replies: 4
» Views: 683
|
Calculating and Reproduci...
Forum: Obi Fluid
Last Post: ZacharyP
18-12-2024, 05:49 PM
» Replies: 2
» Views: 782
|
Null Reference, actor not...
Forum: Obi Rope
Last Post: josemendez
13-12-2024, 12:39 PM
» Replies: 1
» Views: 173
|
Issue with Grasping ObiRo...
Forum: Obi Rope
Last Post: josemendez
12-12-2024, 12:00 PM
» Replies: 5
» Views: 484
|
Changing extruded rendere...
Forum: Obi Rope
Last Post: aderae
10-12-2024, 07:35 PM
» Replies: 2
» Views: 255
|
Baking a rope is causing ...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 11:06 AM
» Replies: 6
» Views: 673
|
Barrier belt - changing l...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 10:42 AM
» Replies: 1
» Views: 227
|
Path editor gizmo's appea...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 09:50 AM
» Replies: 1
» Views: 222
|
Problems when using multi...
Forum: Obi Cloth
Last Post: Cat3Man
09-12-2024, 03:17 AM
» Replies: 2
» Views: 304
|
|
|
Broken scripts with update 6 -> 7 |
Posted by: hariedo - 21-12-2024, 10:35 AM - Forum: Obi Rope
- Replies (2)
|
|
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
|
|
|
Issue with Grasping ObiRope Using Two ToolsGood morning, I’m encountering a strange |
Posted by: alicecatalano - 10-12-2024, 10:45 AM - Forum: Obi Rope
- Replies (5)
|
|
Good morning,
I’m encountering a strange issue with grasping a closed-loop ObiRope using two tools. My goal is to grasp different points on the rope with each tool, without using constraints.
The Problem: - If I grasp the rope with the left tool first and then with the right tool, everything works as expected. Both tools hold their grasping points correctly.
- However, if I grasp the rope with the right tool first and then with the left tool, the following happens:
- The right tool keeps its constraint but the grasped particle shifts to a position far away from the intended grasping point, while still visually connected to the tip of the tool.
- The rope responds to tool movements but maintains this unnatural offset for the right tool.
- The issue only happens when the right tool is the second to grasp, and it occurs inconsistently.
I’ve attached an image showing the situation. The rope becomes distorted, with the grasped particle connected incorrectly.
What I’ve Tried:- Confirming the attachments are created dynamically at runtime without pre-existing constraints.
- Checking that particle indices are updated correctly during grasping.
- Ensuring the tools have unique attachment components.
Image Explanation:
In the attached image:- The left tool is holding the rope correctly.
- The right tool exhibits the described offset issue when grasping second.
Question: Why does this behavior occur when the right tool is the second one to grasp? Could this be a bug in ObiRope's particle attachment system, or am I missing something in the setup?
Thank you for any insights or suggestions!
|
|
|
Barrier belt - changing length and moving anchors |
Posted by: IceTrooper - 09-12-2024, 11:22 PM - Forum: Obi Rope
- Replies (1)
|
|
Hey, I would like to, in my VR app, make a barrier belt, like in cinemas at the box office or airports to cordon off aisles.
This is my script that I made along the lines of a similar script I found in examples (grapling hook) (I cannot post it in the message because of error)
https://pastebin.com/sC54e9fh
I noticed three main problems:
1. A visual bug, as if the UV scale increases indefinitely. I have no idea what this could be. (video in attachments)
2. Particles are not forming where the Rope length has been increased. You can see better in the screenshot what I mean.
3. When I move an object quickly in the editor, the Obi Particle Attachment doesn't seem to keep up. Does this problem only occur in the editor? Is there any way to improve it? (video in attachments)
4. When I select the ‘Roll-Out Rope’ object on the hierarchy then I get a spam on the console:
Code: Look rotation viewing vector is zero
UnityEngine.Quaternion:LookRotation (UnityEngine.Vector3)
Obi.ObiRopeCursorEditor:DrawGizmos (Obi.ObiRopeCursor,UnityEditor.GizmoType) (at Assets/Obi/Editor/RopeAndRod/ObiRopeCursorEditor.cs:91)
UnityEngine.GUIUtility:ProcessEvent(int,intptr,bool&).
I need help with these problems described above. Maybe this can be written better using other APIs, if so I would welcome comments.
|
|
|
Move + attach particle sometimes is offset from the intended move position |
Posted by: ShawnF - 05-12-2024, 07:28 PM - Forum: Obi Rope
- Replies (2)
|
|
Hi,
In my game, you can jump on and swing from ropes. When your rope grab collider hits a particle on the rope, I move that particle to a specific position and then create an attachment (triggered when the rope grab collider hits any particle on the rope):
Code: // Move the collided particle to the char's hand pos
Vector3 relativePlayerPos = attachedRopeChar.attachTransform.position - solver.transform.position;
solver.positions.SetVector3(particleIndex, relativePlayerPos);
// Create a new attachment and set it to be attached to the character's hand
attachment = obiRope.gameObject.AddComponent<ObiParticleAttachment>();
attachment.target = attachedRopeChar.attachTransform;
This USUALLY works, but about 1/4 of the time there's a small offset between the attach point and the location it was supposed to move to. This seems to happen no matter when I move the particle to the hand, even if it's every frame. Here's a video of the normal correct functionality and also how it looks when it's offset:
https://youtu.be/somDPpYDT6o
I haven't figured out a repro for the issue. Strangely, it seems like on a given playthrough, it either works perfectly every time OR it's offset every time for that entire playthrough. It will randomly then be working or not working again on the next playthrough. This makes me think that there's something about the random starting conditions of the game that's causing it - maybe some Obi's LateFixedUpdate somehow gets out of sync with the timing of the game?
Some other info that might help:
- Obi version 6.5.4
- I'm using Fixed Late Updater with 4 substeps
- Initial attachment is triggered by Solver_OnCollision
|
|
|
Disabling solver with 7.0.3 |
Posted by: aderae - 03-12-2024, 07:23 PM - Forum: Obi Rope
- Replies (2)
|
|
Hello,
I recently upgraded from V6 to V7.0.3. I have a world where there can be a lot of ropes around but if player is not engaging with them they are mostly static and standing there. Even though they are not doing anything visibly they were consuming a lot of resources and costing me lots of FPS. In v6 I had a system, if a rope is players out of range I just removed the ropes solver from the ObiFixedSolver list and it was being perfectly rendered, stayed in the world but just didn't do any calculations until player gets close to the rope. This approach saved me a lot of FPS.
Now after 7.0.3 upgrade since ObiFixedSolver is no more, I don't have any way to do this. I can manually disable ropes Obi Solver but now it is completely removed from the world and no longer rendered if I do that. Do I have any way to turn the simulation off for a specific rope while keeping it rendered in the world?
Thanks in advance.
|
|
|
Rope moving in runtime |
Posted by: Apoll0 - 02-12-2024, 02:46 PM - Forum: Obi Rope
- Replies (5)
|
|
Hello!
I have a Rope with two static attachments on it's endings.
I need to periodically show this rope in different places of the scene, between different objects in space.
I use only one rope, simply turning it and it's attachments off and on when needed (by gameobject.setActive). The problem is that if you turn it on, pause for half a second, for example, and then move the attachments to the desired positions, then everything is ok, rope moves there it should be (with wild stretching, but ok).
But if you turn it on and immediately give the attachments new positions, then the rope don't moves from its place.
What is the best way to move the attachments (these are ordinary empty Transforms) so that the rope immediately moves to the desired place and stays there until the next turn off?
|
|
|
|