Obi Official Forum
Bug / Crash Deleting instances of prefabs cause a bug in play mode - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Bug / Crash Deleting instances of prefabs cause a bug in play mode (/thread-2734.html)



Deleting instances of prefabs cause a bug in play mode - ThisIsFine - 03-02-2021

Hello,

I've encountered a bug in my project, and was able to encounter it again on a new clean projet. I'm using Unity 2019 LTS and Obi Rope 5.6.2

1. I've a prefab, containing two objects dynamically linked by a rope. The solver is inside the prefab (with ObiFixedUpdater)

2. I put 3 instances of this prefab in a simple scene

3. Then, if I delete A, then B, then C, everything is fine...
BUT ! If I delete C first, there is a big bug, and ropes from A go crazy and jump (or the spheres/cubes fly away) ! The attachment is almost broken (there is a big gap between the rope and the sphere)

Could you help me/resolve this bug ?
I can send a zip package is necessary,

Thanks,


RE: Deleting instances of prefabs cause a bug in play mode - josemendez - 03-02-2021

(03-02-2021, 12:18 PM)ThisIsFine Wrote: Hello,

I've encountered a bug in my project, and was able to encounter it again on a new clean projet. I'm using Unity 2019 LTS and Obi Rope 5.6.2

1. I've a prefab, containing two objects dynamically linked by a rope. The solver is inside the prefab (with ObiFixedUpdater)

2. I put 3 instances of this prefab in a simple scene

3. Then, if I delete A, then B, then C, everything is fine...
BUT ! If I delete C first, there is a big bug, and ropes from A go crazy and jump (or the spheres/cubes fly away) ! The attachment is almost broken (there is a big gap between the rope and the sphere)

Could you help me/resolve this bug ?
I can send a zip package is necessary,

Thanks,

Hi there,

If you could send a .zip of the project to support(at)virtualmethodstudio.com I will take a look at it. I don't quite understand your description.

kind regards,


RE: Deleting instances of prefabs cause a bug in play mode - ThisIsFine - 03-02-2021

Ok no problem, I've sent you my project.
Thank you


RE: Deleting instances of prefabs cause a bug in play mode - josemendez - 04-02-2021

(03-02-2021, 12:58 PM)ThisIsFine Wrote: Ok no problem, I've sent you my project.
Thank you

Hi there,

Haven't received anything yet, just letting you know. cheers!


RE: Deleting instances of prefabs cause a bug in play mode - ThisIsFine - 04-02-2021

(04-02-2021, 09:10 AM)josemendez Wrote: Hi there,

Haven't received anything yet, just letting you know. cheers!

Weird !
I've send it again, but this time using WeTransfer.


RE: Deleting instances of prefabs cause a bug in play mode - josemendez - 04-02-2021

Got it! Will get back to you asap.


RE: Deleting instances of prefabs cause a bug in play mode - josemendez - 04-02-2021

This is a known bug in dynamic attachments, introduced in 5.6.1 and fixed in 6.0 (yet unreleased). A quick fix is to open up ObiParticleAttachment.cs, and just remove/comment out line 456:

Code:
//if (torn)   // <---comment this out
m_Actor.SetConstraintsDirty(Oni.ConstraintType.Pin);



One thing I though I should point out about your current setup: you're using an independent updater/solver for each prefab instance. This is a big no-no. This means each solver and its rope will be updated sequentially, negating most multithreading benefits. Usually you're supposed to have a single Updater component in your scene that updates all solvers in parallel. See:
http://obi.virtualmethodstudio.com/tutorials/bigpicture.html
http://obi.virtualmethodstudio.com/tutorials/updaters.html

To make things worse, all updaters use 3 substeps and have "substep unity physics" enabled. This will force rigidbody physics in your scene to be updated 3 times per updater, for a total of 9 full physics updates per frame. For very simple scenes it might be ok, but as soon as you add a few more ropes it will absolutely obliterate performance.

let me know if I can be of further help. cheers!


RE: Deleting instances of prefabs cause a bug in play mode - ThisIsFine - 04-02-2021

(04-02-2021, 10:45 AM)josemendez Wrote: This is a known bug in dynamic attachments, introduced in 5.6.1 and fixed in 6.0 (yet unreleased). A quick fix is to open up ObiParticleAttachment.cs, and just remove/comment out line 456:

Code:
//if (torn)   // <---comment this out
m_Actor.SetConstraintsDirty(Oni.ConstraintType.Pin);



One thing I though I should point out about your current setup: you're using an independent updater/solver for each prefab instance. This is a big no-no. This means each solver and its rope will be updated sequentially, negating most multithreading benefits. Usually you're supposed to have a single Updater component in your scene that updates all solvers in parallel. See:
http://obi.virtualmethodstudio.com/tutorials/bigpicture.html
http://obi.virtualmethodstudio.com/tutorials/updaters.html

To make things worse, all updaters use 3 substeps and have "substep unity physics" enabled. This will force rigidbody physics in your scene to be updated 3 times per updater, for a total of 9 full physics updates per frame. For very simple scenes it might be ok, but as soon as you add a few more ropes it will absolutely obliterate performance.

let me know if I can be of further help. cheers!


It's working now ! Thank you a lot for your efficiency Sonrisa  

Yes, for my original project (not the simple that I made to send for the bug report), I've one Updater, and dynamically add/remove solvers to it. The number of substeps is relative to the number of solvers.

Have a good day !


RE: Deleting instances of prefabs cause a bug in play mode - josemendez - 04-02-2021

You're welcome! Have a good day too Sonrisa