Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Resetting Rope causing Error
#3
(07-08-2024, 07:13 AM)vrtraining Wrote: Okay I have solved the issue by using the following new code


Code:
public void ResetRope()
    {
        rope.ResetParticles();
        ropeCursor.ChangeLength(initialLength - rope.restLength);
    }

I didn't knew about ResetParticles() before, is there is any major difference between my previous and new approach. It seems to does the trick for me.

Hi!

ResetParticles() is much faster, as it doesn't take the entire rope out of the solver and then re-add it: it just resets particle data to whatever's in the blueprint. RemoveFromSolver()/AddToSolver() would destroy all particle/constraint data for that actor and recreate it anew, and trigger a full rebatching of all constraints in the solver.

However, ResetParticles won't reset constraints or elements (it only resets particles as the name implies) so if you're changing the length or the rope -which means constraints and elements are added at runtime- it won't work.

Also be mindful of *when* you call RemoveFromSolver() / AddToSolver(). In Obi 6 these are safe to be called anytime except FixedUpdate(), in Obi 7 calling them during Update() would result in them being called while the simulation is running, and you'd be pulling the rug from under the simulation's feet by modifying state from the main thread.

We'll upload updated API docs for Obi 7 later today, were these differences are highlighted.

kind regards,
Reply


Messages In This Thread
Resetting Rope causing Error - by vrtraining - 06-08-2024, 06:33 PM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 07:13 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 08:06 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 08:47 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 09:38 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 09:40 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 10:20 AM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 10:45 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 11:53 AM
RE: Resetting Rope causing Error - by josemendez - 07-08-2024, 12:15 PM
RE: Resetting Rope causing Error - by vrtraining - 07-08-2024, 12:50 PM