05-10-2023, 06:42 AM
(04-10-2023, 09:33 PM)Lazerpants Wrote: Hello!
I have the rope set up in such a way where one spawns after the player character fires a bow at the ceiling, and when the arrow hits the ceiling, a rope extends downward, so that the character can climb up it. When the arrow hits the ceiling, everything spawns (solver, updater, renderer, etc.), along with a weight at the bottom of the rope so that the rope is always calm and held down as it gradually extends towards the ground.
Hi!
Having one updater per rope will yield rather poor performance, since it forces all ropes in your scene to be simulated sequentially - instead of taking advantage of multithreading. Ideally you should have a single updater per scene, in charge of updating all your solvers. This is far more efficient. See:
http://obi.virtualmethodstudio.com/manua...aters.html
http://obi.virtualmethodstudio.com/manua...cture.html
Having one solver per rope is also very wasteful, unless each rope requires different global parameters (such as the reference frame, gravity, or constraint settings).
(04-10-2023, 09:33 PM)Lazerpants Wrote: Now I'm trying to change it so that there's only 1 rope at a time. When the player character fires another arrow at the ceiling, I want it to destroy the previous rope and then just make a new one in the new location. I'm using Unity's standard Destroy() method to destroy the rope parent (which has the solver and updater attached to it, then the rope itself which is a child, and the weight which is a separate object that's a child of the rope). Deleting the object throws no errors by itself. However, when I then go to shoot a new arrow to spawn a new rope, Unity starts throwing endless errors, which pertain to the Rigidbody of the weight object.
I'm assuming from the errors that the Obi code somewhere is trying to access/update the rigidbody that was attached to the weight at the bottom of the original rope, which has since been destroyed and no longer exists. Is there something I need to call first before destroying the rope, solver, and rigidbody so I can spawn the new rope without errors?
At which point in the frame are you calling Destroy() on the updater/solver/rope/rigidbody? I can only imagine this being an issue if you do it during the updater's update cycle, since it will prevent it from cleaning up data associated to destroyed rigidbodies.
kind regards,