Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tons of problems trying to simulate simple rope without elasticity
#26
(23-02-2022, 04:37 PM)Romahaaa Wrote: Hm.. Then it will be pretty hard to find the real issue... Maybe some 3rd party asset conflict..

Hi there,

Could successfully reproduce, find and fix the issue. The culprit was indeed component update order:

The modified script I sent you hooks to the actor's OnInterpolate event. There, it forces the renderable position of the attached particle to be that of the attachment point. So far so good.

Problem is, the ObiPathSmoother component that prepares the rope for rendering also does its work by subscribing to in OnInterpolate. Both ObiParticleAttachment and ObiPathSmoother subscribe to OnInterpolate() during their OnEnable() method.

Since the order in which Unity calls events (Awake(),OnEnable(),Update(), etc) for different objects is undefined by default, you get two possible outcomes:

A) the attachment subscribes first, the path smoother second. Every frame, the attachment modifies the particle's position and then the smoother renders it. All works good.

B) the path smoother subscribes first, the attachment second. Every frame, the smoother renders the rope and then the attachment modifies the particle's position, but this has no effect since the rope has already been rendered. Bummer.

This was hard to reproduce since either A) or B) would happen entirely *at random*. Can be fixed by changing script update order in Unity, but the best, most robust fix is to ensure the attachment snaps the particle position before OnInterpolate. This can be done by subscribing to the solver's OnInterpolate (which is called right before all actors have their OnInterpolate event triggered) instead of the actor's.

I've attached an patched script. My apologies for not catching this one sooner!

let me know if I can be of further help.


Attached Files
.cs   ObiParticleAttachment.cs (Size: 21.77 KB / Downloads: 15)
Reply


Messages In This Thread
RE: Tons of problems trying to simulate simple rope without elasticity - by josemendez - 24-02-2022, 12:17 PM