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


Messages In This Thread
RE: How do you properly destroy an Obi Rope at runtime? - by josemendez - 15-01-2019, 07:41 PM