Search Forums

(Advanced Search)

Latest Threads
Broken scripts with updat...
Forum: Obi Rope
Last Post: hariedo
Yesterday, 10:35 AM
» Replies: 0
» Views: 41
Garment explodes on Andro...
Forum: Obi Cloth
Last Post: CptnFabulous
19-12-2024, 07:16 AM
» Replies: 4
» Views: 666
Calculating and Reproduci...
Forum: Obi Fluid
Last Post: ZacharyP
18-12-2024, 05:49 PM
» Replies: 2
» Views: 768
Null Reference, actor not...
Forum: Obi Rope
Last Post: josemendez
13-12-2024, 12:39 PM
» Replies: 1
» Views: 161
Issue with Grasping ObiRo...
Forum: Obi Rope
Last Post: josemendez
12-12-2024, 12:00 PM
» Replies: 5
» Views: 464
Changing extruded rendere...
Forum: Obi Rope
Last Post: aderae
10-12-2024, 07:35 PM
» Replies: 2
» Views: 244
Baking a rope is causing ...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 11:06 AM
» Replies: 6
» Views: 658
Barrier belt - changing l...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 10:42 AM
» Replies: 1
» Views: 217
Path editor gizmo's appea...
Forum: Obi Rope
Last Post: josemendez
10-12-2024, 09:50 AM
» Replies: 1
» Views: 214
Problems when using multi...
Forum: Obi Cloth
Last Post: Cat3Man
09-12-2024, 03:17 AM
» Replies: 2
» Views: 292

 
  does not render correctly in Unity 6000
Posted by: Yumineko - 29-06-2024, 10:29 AM - Forum: Obi Fluid - Replies (3)

Hi

As the title says, I am using Unity6000 0.5f1.
I imported Obi Fluid and followed the manual, but in every sample the fluid turns black and I keep getting warnings.

Based on troubleshooting, URP15/16 patches have already been applied.
I converted the material for URP and set the RendererFeature as instructed on the setup page.

Unity 6000 (URP 17) is not yet supported ?

Print this item

  Elastic Stretch Arm for VR Avatar Hands with Physics
Posted by: Sky d - 28-06-2024, 12:55 PM - Forum: Obi Rope - Replies (1)

Hello,
I happen to be in the middle of a VR hackathon and I've been tasked with developing a stretchy arm for our first person player.   I would like to apply custom hands and forearm to the player skeleton and add the ability that when they grab something, they can outstretch their arms like "elastic man" to position the object far away from them.  It also would be nice if I could a apply a bit of curve and flexibily to the arm.  But the hand should still be able to have it's basic vR functions untinterrupted.

I mostly use Obi rope for cable and rope simulations but it occurred to me that I could try the stretch + Bone components in my scenario.    I would just need to know for sure if it's realistic thinking that I can access the stretch distance parameters via thumbstick controller if I wanted.

I would appreciate any tips or ideas in this direction while I continue trying to hack it out based on documentation.  
Thanks much

Here's a reference I found of someone with a different type of mechanic using stretchy arms...  I wish to make something that is more slow and controlled.
https://www.youtube.com/watch?v=nM81-lH79YE

Print this item

  Proxies with SkinnedMeshRenderers
Posted by: grigler - 27-06-2024, 03:28 PM - Forum: Obi Cloth - Replies (2)

Hey,

The documentation for cloth proxies says that they should be usable with either skinned cloths or normal cloths, however from looking at the code it seems like it's being driven from the MeshFilter component, which isn't a requirement of the SkinnedMeshRenderer.

is there an alternative?

Edit: Additionally, this cloth solution doesn't have a clear way of how to manage LODGroups. The results seem to be that any cloth will always be visible, breaking the lodgroup

Print this item

  Softbody-based Crawling
Posted by: wenhao_zheng - 27-06-2024, 10:40 AM - Forum: Obi Softbody - Replies (3)

Hi! 

As shown in the figure below, I try to use two soft bodies to grab a rigid body. For example, a claw machine.I expect the grabbing process to be achieved through friction.

I set the same collision material for both the claw soft body and the rigid body, with both dynamic and static friction set to 1.
In my attempt, I was able to grab the rigid body, but it soon fell slowly. In the real world, I would think that the friction is not enough. But I have set the friction to 1 in the collision material, and I expect that there should be no tangential movement of the object.
For reference I have attached my Obi Solver component configuration, although I have tried different things with it and I don't think the problem seems to be there.
Is it possible to achieve my needs based on ObiSoftbody? If it is feasible, I am very much looking forward to getting suggestions from developers.
Many thanks!

Please see the attachment for detailed configuration.
Thanks!



Attached Files Thumbnail(s)
                   
Print this item

  helicopter hook
Posted by: Koolio - 26-06-2024, 11:19 PM - Forum: Obi Rope - Replies (4)

Any guide or example on making a rope that works like a helicopter hook, ie bit like the jungle strike games.. where the end of the hook can latch onto gameobjects to pick them and swing them, but also hoist them up so the rope length would get shorter?

is this something simple that can be done with obi rope?

Print this item

Pregunta Particle Attachment on expanding rope
Posted by: Balou - 26-06-2024, 01:43 AM - Forum: Obi Rope - Replies (3)

Hi,

I've a rope around 1 unit long, it's attached to a rod by the first and last particle with 2 static particle attachments.
On this rope there is cursor, depending on an object position (a VR controller) the cursor will either have the cursor at 0 or 1 (source always at .5) . Imagine you are pulling a rope either from the start or end.
So this rope can get bigger if you pull, everything works fine here.
Now when pulling I want to attach the closest particle from the controller to it. I'm getting the closest particle (avoiding the first and last) and create the attachment using this script:

Code:
                particleAttachment = rope.gameObject.AddComponent<ObiParticleAttachment>();
                particleAttachment.enabled = false;
                particleAttachment.target = m_Controller;

                var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
                group.particleIndices.Add(attachedParticleIndex);
                group.name = "Test";


                particleAttachment.particleGroup = group;
                particleAttachment.attachmentType = ObiParticleAttachment.AttachmentType.Static;
                particleAttachment.enabled = true;

And the behavior is weird, sometimes it works, sometimes points get stuck in the air like if they were attach to a world position. I feel like it's because I'm expanding the rope while dragging and sometimes the source particle can become the one attached?

Do you see any edge cases with this system?

Thanks a lot.

Print this item

  Shadow Problem
Posted by: 0xhex - 25-06-2024, 06:19 PM - Forum: Obi Fluid - Replies (1)

Hello,there is something wrong with shadows on fluids,
i will share 2 screenshot one for with shadow, one without shadow

in shadow it looks weird,i need to disable shadows for fluid particles!

[Image: kb0t27n.png]

[Image: s7boin9.png]

Print this item

  Elastic Deformation Question
Posted by: wenhao_zheng - 25-06-2024, 07:32 AM - Forum: Obi Softbody - Replies (2)

Hi! Sonrojado

I want to simulate human soft tissues through the ObiSoftbody toolkit.
I have two questions, both of which do not consider plastic deformation, but only elastic deformation:
① How to modify the elastic deformation effect of the soft body. For example, the elasticity of fat is different from that of muscle. I modified the Shape Matching Constraints in the test, but the effect does not seem to meet expectations.
② I want to simulate the elasticity value of each soft tissue, so I am considering obtaining the deformation of each particle through the API for calculation. Is my idea correct?

Thank you for your attention, I really want to know how to do my work, thank you. Gran sonrisa

Print this item

  Collision detection problom
Posted by: MakeLifeEasier - 24-06-2024, 04:07 AM - Forum: Obi Cloth - Replies (2)

Sorry to bother you. I want to create a system where when a cloth net collides with a rigid body, it indicates whether a collision has occurred. If a collision occurs, the scene should be reinitialized. However, with the current code, even though collisions appear to happen on screen, there is no indication of a collision being detected.
Here is the code attached to the  obi solver,  

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class CollisionEventHandlerchuang : MonoBehaviour
{
    ObiSolver solver;
    public int contactCount;
    private bool collisionOccurred = false;

    void Awake()
    {
        solver = GetComponent<ObiSolver>();
    }

    void OnEnable()
    {
        solver.OnParticleCollision += Solver_OnCollision;
    }

    void OnDisable()
    {
        solver.OnParticleCollision -= Solver_OnCollision;
    }

    void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {

        contactCount = 0;
        collisionOccurred = false;

        //foreach (var contact in e.contacts)
        //{
        //    if (contact.distance < 0.001f)
        //    {
        //        collisionOccurred = true;
        //        contactCount++;
        //    }
        //}

        var world = ObiColliderWorld.GetInstance();

        // just iterate over all contacts in the current frame:
        foreach (Oni.Contact contact in e.contacts)
        {
            // if this one is an actual collision:
            Debug.Log("no bang chuang");
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                if (col != null)
                {
                    Debug.Log("bang chuang");
                    collisionOccurred = true;
                    contactCount++;
                }
            }
        }

    }

    public bool IsCollisionOccurred()
    {
        return collisionOccurred;
    }

    public int GetContactCount()
    {
        return contactCount;
    }

    void OnDrawGizmos()
    {
        // Existing OnDrawGizmos code
    }
}
Here is another code subscribed the collision event,  it is expected to return true when the collision happens. However, the false is always returned.
Code:
using System.Collections.Generic;
using Unity.MLAgents;
using UnityEngine;
using Obi;

public class SatelliteEnvController : MonoBehaviour
{
   
    public ObiSolverInitializer obiSolverInitializer;

    public CollisionEventHandlerchuang collisionHandlerchuang;
    public CollisionEventHandler collisionHandler;


    void Start()
    {
   
        ResetScene();
        obiSolverInitializer.InitializeObiSolverPosition();

        collisionHandlerchuang = FindObjectOfType<CollisionEventHandlerchuang>();
        collisionHandler = FindObjectOfType<CollisionEventHandler>();

        if (collisionHandlerchuang == null)
        {
            Debug.LogError("CollisionEventHandlerchuang not found in the scene.");
        }
        if (collisionHandler == null)
        {
            Debug.LogError("CollisionEventHandler not found in the scene.");
        }

    }

    void FixedUpdate()
    {
        if (collisionHandlerchuang != null)
        {
            bool collisionOccurred = collisionHandlerchuang.IsCollisionOccurred();
            int contactCount = collisionHandlerchuang.GetContactCount();

            Debug.Log("Collision occurred: " + collisionOccurred);
            Debug.Log("Number of contacts: " + contactCount);

        }
    }

   

Print this item

Exclamación Rope saving and restore by Json
Posted by: tapLucas - 22-06-2024, 03:32 PM - Forum: Obi Rope - Replies (19)

Dev environment: Obi Rope version 6.5.4 / Windows 10 / Unity 2021


Hello, sorry to bother you.  I am working on a puzzle game and need to save the data of twisted ropes into a JSON file, then read the JSON during gameplay to restore the ropes to their previous twisted state. ()



I have implemented the save and load functions and can confirm that the saved data is correct because I have tested the vectors' paths of the ropes, and they match what was saved.

However, when I apply the data to the instantiated ropes, I cannot restore the ropes to their previous state. When I use the vectors stored in JSON to restore the positions of the rope's particles, the ropes can never maintain their previous twissted state. The ropes are always spread out or lying there alone.


I found some posts in the forum:

https://obi.virtualmethodstudio.com/foru...-116.html?
The first post from 2017 mentioned frequently calling ObiRopeCursor.ChangeLength() to restore the shape of the ropes, but this method does not work for me, and I am also unable to call the PushDataToSolver method mentioned in the post. (This method only implemented in class ObiStitcher) However, I understand the reason for calling ObiRopeCursor.ChangeLength(). Calling this method can increase the activeParticleCount. The number of actor.activeParticleCount may be much smaller than the number of actor.particleCount, but the number of actor.particleCount is limited by the particleCount in ObiActorBlueprint.

https://obi.virtualmethodstudio.com/foru...4112.html?
The second post was updated in February 2024, which is very recent and provides sample code. The save and load code in the post is very similar to mine, with the only difference being that the loop code during restoration ignores the legality of solver.positions[particlesIndices[i]]. During actual operation, the number of _rope.solverIndices may be much smaller than the total amount of data stored in JSON, resulting in either loss of some data or array out-of-bounds errors.


Here is the code I used to instantiate the rope / saving and restoring the ropes.


Instantiate the rope:
 
Code:
private GameObject InstantiateRope(GameObject objectToAttach1, GameObject objectToAttach2)
    {
        var rpObject = objectPool.GetRopeFromPool();
        ObiRope rope = rpObject.GetComponent<ObiRope>();
       
        Transform transformA = objectToAttach1.transform;
        Transform transformB = objectToAttach2.transform;
        Vector3 PositionA = transformA.position;
        Vector3 PositionB = transformB.position;
        Vector3 objectScale = transformA.localScale;
       
        Vector3 offset = new Vector3(0, objectScale.y + 0.05f, 0);

        Vector3 startPositionLS = transform.InverseTransformPoint(PositionA + offset);
        Vector3 endPositionLS = transform.InverseTransformPoint(PositionB + offset);
        //Vector3 tangentLS = (endPositionLS - startPositionLS).normalized;
        Vector3 tangentLS = Vector3.zero;

       
        ObiRopeBlueprint blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
        blueprint.path.Clear();
        blueprint.pooledParticles = 100;
       
        // Build the rope path:
        int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
        blueprint.path.AddControlPoint(startPositionLS, -tangentLS, tangentLS, Vector3.up, 1f, 0.1f, ropeThickness, filter,
            Color.white, "start");
       
        blueprint.path.AddControlPoint(endPositionLS, -tangentLS, tangentLS, Vector3.up, 1f, 0.1f, ropeThickness, filter,
            Color.white, "end");
       
        blueprint.path.FlushEvents();

        // Generate particles/constraints:
        blueprint.GenerateImmediate();
       
        ObiParticleAttachment attachment1 = rpObject.AddComponent<ObiParticleAttachment>();
        ObiParticleAttachment attachment2 = rpObject.AddComponent<ObiParticleAttachment>();

        // Set the blueprint:
        rope.ropeBlueprint = blueprint;
       
        // Attach both ends:
        attachment1.target = transformA;
        attachment2.target = transformB;
        attachment1.particleGroup = blueprint.groups[0];
        attachment2.particleGroup = blueprint.groups.Last();

        // Parent the actor under a solver to start the simulation:
        rpObject.transform.SetParent(obiSolverObject.transform);
       
        return rpObject;
    }


Save the positions of the particles in the rope:
 
Code:
public JSONObject SaveJson()
    {
        jsonObject.AddField("ropeLength", gameObject.GetComponent<ObiRope>().restLength);
        jsonObject.AddField("particles", GetRopeParticleData());
        return jsonObject;
    }

  JSONObject GetRopeParticleData()
    {
        var rope = gameObject.GetComponent<ObiRope>();
        var solver = rope.solver;
        var particlesIndices = rope.solverIndices;
        var positions = new List<Vector3>();
       
        for (int i = 0; i < particlesIndices.Length; i++)
        {
            //if (rope.IsParticleActive(i))  // I was considering save active particles only.
            {
                positions.Add(solver.positions[particlesIndices[i]]);
            }
        }
        var positionsArray = JSONObject.emptyArray;
        for (int i = 0; i < positions.Count; i++)
        {
            positionsArray.Add((JSONNode)positions[i]);
        }

        var ropeObject = JSONObject.emptyObject;
        ropeObject.AddField("positions", positionsArray);
        //ropeObject.AddField("velocities", velocitiesArray);  // Velocities are all zero, so I didn't save.
        return ropeObject;
    }




Load the positions of the particles from JSON and set to particles in the rope:

   
Code:
public void LoadJson(JSONObject jsonObject)
    {
        ropeLength = jsonObject["ropeLength"].floatValue;
        gameObject.GetComponent<ObiRopeCursor>().ChangeLength(RopeLength);
        particleDataToRestore = jsonObject["particles"];
        rope.OnBlueprintLoaded += Actor_OnBlueprintLoaded;
    }

public void Actor_OnBlueprintLoaded(ObiActor actor, ObiActorBlueprint blueprint)
    {
        if (particleDataToRestore == null)
            return;
        var solver = actor.solver;
        var particlesIndices = actor.solverIndices;

        /*for (int i = 0; i < actor.solverIndices.Length; ++i)
            solver.invMasses[actor.solverIndices[i]] = 0;*/
       
        var positionsJsonArray = particleDataToRestore["positions"];
        if (positionsJsonArray != null && positionsJsonArray.type == JSONObject.Type.Array)
        {
            for (int i = 0; i < positionsJsonArray.list.Count; i++)
            {
                if (i < particlesIndices.Length)
                {
                    solver.positions[particlesIndices[i]] = positionsJsonArray[i].ToVector3();
                    // actor.ActivateParticle(i);
                }
            }
        }
       
        /*for (int i = 0; i < actor.solverIndices.Length; ++i)
            solver.invMasses[actor.solverIndices[i]] = 1f;*/
       
        particleDataToRestore = null;
    }



Attached Files Thumbnail(s)
               
Print this item