Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Issue Saving/Loading Particle Positions in play mode using ObiRope v7.0
#4
(29-04-2025, 07:53 AM)josemendez Wrote: Hi!


It always uses activeParticleCount now. It's by far the most common case and the most efficient one as well: activate the last inactive particle, which is done by just bumping a counter.


This code appends a new element that links the first particle of the previous element with the new active particle. It should link the second particle of the previous element instead.


Corrected the above two issues (ActivateParticle and reversed elements), tested it and it seems to work ok. Could you specify what you mean by "not working"? does it result in an error? does it do nothing? does it do something else that what you expected?

kind regards,



Hello, thank you for your response .

First of all, I want to ask this:
When I directly instantiate the ObiRope prefab and place it into the solver, since it doesn't have any particles yet, this line throws the following error:

Code:
rope.ActivateParticle();
Code:
IndexOutOfRangeException: Reading from index 0 is out of range of '0' Capacity.
Obi.ObiNativeList`1[T].get_Item (System.Int32 index) (at Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs:83)
Obi.ObiActor.ActivateParticle () (at Assets/Obi/Scripts/Common/Actors/ObiActor.cs:628)
Rope.Load (UnityEngine.Vector3[] particlePositions, UnityEngine.Vector3 lastParticlePosition) (at Assets/_Game/Scripts/Rope/Rope.cs:206)

To overcome this, I first spawn the rope and then load the saved data:

Code:
Rope rope = Spawner.Instance.CreateRope(startAttachmentPoint.PinPoint);
rope.SetStartPin(startAttachmentPoint);
rope.SetEndPin(endAttachmentPoint);
await UniTask.Delay(100);
rope.Load(data.particlePositions, data.lastParticlePositions);

Is there a way to remove this delay?
Code:
await UniTask.Delay(100);




As for my main issue, if I use the Load() method I sent in my first message exactly as it is, none of the particle positions are set. They all remain in their initial positions. In other words, my rope appears as it was set in the blueprint. I suspect this happens because it's an asynchronous process, but I’m not sure.

Thank you.
Reply


Messages In This Thread
RE: Issue Saving/Loading Particle Positions in play mode using ObiRope v7.0 - by ozeecode - 29-04-2025, 08:55 AM