Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extend a rope when the attached object shot from a position
#10
(29-09-2022, 10:08 AM)lacasrac Wrote: 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...

Hi,

You've created an empty particle group, hence the null ref exception: there's no particles in the group to copy to the attachment. You need to first specify which particles are part of the group. Like this:

Code:
var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
group.particleIndices.Add(particleIndex); //<-- add at least one particle to the group.
_lastAttachment.particleGroup = group;

There's no need to give a name to the group or make it part of the blueprint unless you later want to retrieve it by name.

kind regards,
Reply


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