Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Assigning target to ParticleAttchment component at runtime
#6
(20-12-2019, 10:19 AM)VirtualCucumber Wrote: Through Awake its fine.

I set the particleGroups made on that BP to 0 collision phase and then by default the ObiCollider is 0 for the block and still same thing.

I then I added this fast into the script to manually set the position tooo
Code:
using UnityEngine;
using Obi;

public class DummyAttach : MonoBehaviour
{
   public Transform target;

   private ObiRope _rope;
   private ObiParticleAttachment _attachment;

   private void Start()
   {
       _rope = GetComponent<ObiRope>();
       _attachment = GetComponent<ObiParticleAttachment>();

       var index = _rope.solverIndices[0];
       var targetPos = _rope.solver.transform.InverseTransformPoint(target.position);
       _rope.solver.invMasses[index] = 0f;
       _rope.solver.positions[index] = targetPos;

       if (target != null)
           _attachment.target = target;

       //_rope.solver.invMasses[index] = 1f;
   }
}

Resetting the mass is commented out because it just did what its been doing which is attaching to that offset we see in the gif. Not resetting it just attaches it manually with no 2-way physics between the rope and rigidbody which is good for just positioning but I really enjoy the new attachment system and would like to attach through runtime.

Doing the same thing in Awake should also work because you attach the rope immediately, it has no chance to react to collisions.

Regarding the phase (which is set in the path editor, and setting the control point phase value), make sure the rope simply falls down if no attachment is setup. Should not react to the collider at all if done correctly.
Reply


Messages In This Thread
RE: Assigning target to ParticleAttchment component at runtime - by josemendez - 20-12-2019, 10:40 AM