Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How do you properly destroy an Obi Rope at runtime?
#1
If I try to destroy a rope simply using Destroy(gameObject), all other ropes using that solver stop working. I've tried using Solver.RemoveActor(rope), but that results in a whole bunch of weird problems. What is the correct way to go about this?
Reply
#2
When I say all other ropes stop working, it seems that they only stop updating visually. Their bounds and other things are still working and moving correctly, its just visually they stop. If any ropes are added after this, or if the bugged rope is clicked in the inspector, it starts rendering correctly again.


Edit: Using the particle grid debugger, its definitely just the mesh that isn't updating, the particles are all correct.
Reply
#3
Still looking for a solution to this. I don't know if its a bug with ObiRope or if I'm doing something wrong.
Reply
#4
(15-01-2019, 10:38 AM)SamMcG Wrote: Still looking for a solution to this. I don't know if its a bug with ObiRope or if I'm doing something wrong.

Hi SamMcG,

Testing with Obi 3.5 and Unity 2018.1, I'm unable to reproduce this. Ropes are deleted correctly and all other ropes still render as they should (each rope has its own renderer, and generates its own mesh, apart from sharing the same solver they're completely isolated so I don't see how deleting one rope could affect others).

Calling Destroy() is the correct way of destroying any ObiActor, as they remove themselves from the solver they're in automatically upon destruction.

This is the code I'm using to test this, in a scene with around 100 short ropes. I populate the "ropes" list with them, and start pressing "A" to destroy each rope.

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

public class DeleteRopes : MonoBehaviour {

   public List<ObiRope> ropes;

    // Update is called once per frame
    void Update () {
        
       if (Input.GetKeyDown(KeyCode.A) && ropes.Count > 0){
           Destroy(ropes[ropes.Count-1].gameObject);
           ropes.RemoveAt(ropes.Count-1);
       }

    }
}
Reply
#5
(15-01-2019, 07:41 PM)josemendez Wrote: Hi SamMcG,

Testing with Obi 3.5 and Unity 2018.1, I'm unable to reproduce this. Ropes are deleted correctly and all other ropes still render as they should (each rope has its own renderer, and generates its own mesh, apart from sharing the same solver they're completely isolated so I don't see how deleting one rope could affect others).

Calling Destroy() is the correct way of destroying any ObiActor, as they remove themselves from the solver they're in automatically upon destruction.

This is the code I'm using to test this, in a scene with around 100 short ropes. I populate the "ropes" list with them, and start pressing "A" to destroy each rope.

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

public class DeleteRopes : MonoBehaviour {

   public List<ObiRope> ropes;

    // Update is called once per frame
    void Update () {
        
       if (Input.GetKeyDown(KeyCode.A) && ropes.Count > 0){
           Destroy(ropes[ropes.Count-1].gameObject);
           ropes.RemoveAt(ropes.Count-1);
       }

    }
}

Thanks for the reply.

I've tried reinstalling ObiRope but I still get the same bug. It may have something to do with the way I'm creating the ropes. I've spent a long time trying to figure out what exactly is causing it, but it's so inconsistent I haven't made any progress towards stopping it. When I have time, I'm just going to start from the beginning and rewrite my spawning scripts to hopefully avoid this.
Reply