Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How do you properly destroy an Obi Rope at runtime?
#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


Messages In This Thread
RE: How do you properly destroy an Obi Rope at runtime? - by SamMcG - 16-01-2019, 06:37 AM