Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extend a rope when the attached object shot from a position
#9
(28-09-2022, 12:33 PM)josemendez Wrote: I don't see why you would need to add or remove control points at runtime, I think you're misunderstanding the core concept of blueprints. Their only purpose is to specify the initial shape of the rope and particle placement/count at the start, that's it. Once the rope is created and the simulation starts, the blueprint (and the control points) basically stop being used, you're only concerned about particles then. If you wish to add or remove attachments, you can just create/destroy new ObiParticleAttachment components. If you wish to change the length of the rope, you use a cursor.

You don't need to create or destroy control points to create attachments, control points have nothing to do with attachments whatsoever. An attachment is a component that takes a particle group and attaches it to an object. You can simply destroy the attachment to remove it (or even just disable it), you don't need to add or destroy control points in the blueprint.

Note that attachments take a particle group as input, not a control point. Even though the blueprint will create a particle group for each control point for convenience, you can create your own particle groups at runtime since they're just a scriptable object.

I tried that with this code

Code:
                ObiParticleGroup group = ScriptableObject.CreateInstance<ObiParticleGroup>();
                group.SetSourceBlueprint(rope.blueprint);
                group.name = "last_one";
                _lastAttachment.particleGroup = group;


but with no luck

ArgumentNullException: Value cannot be null.
Obi.ObiNativeList`1[T].CopyFrom (Obi.ObiNativeList`1[T] source, System.Int32 sourceIndex, System.Int32 destIndex, System.Int32 length) (at Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs:253)
Obi.ObiPinConstraintsBatch.Merge (Obi.ObiActor actor, Obi.IObiConstraintsBatch other) (at Assets/Obi/Scripts/Common/Blueprints/Constraints/Batches/ObiPinConstraintsBatch.cs:114)
Obi.ObiConstraints`1[T].Merge (Obi.ObiActor actor, Obi.IObiConstraints other) (at Assets/Obi/Scripts/Common/Blueprints/Constraints/ObiConstraints.cs:55)
Obi.ObiSolver.PushConstraints () (at Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1389)
Obi.ObiSolver.BeginStep (System.Single stepTime) (at Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1518)
Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Obi/Scripts/Common/Updaters/ObiUpdater.cs:63)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:46)

Can you share a working example? I cannot find anything in the samples...
Reply


Messages In This Thread
RE: Extend a rope when the attached object shot from a position - by lacasrac - 29-09-2022, 10:08 AM