Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Can't generate rope in runtime. (Unity 2019.3.10f1)
#1
Hello, a code that I use to generate ropes in runtime stopped working when I updated from Unity 2019.2 to 2019.3
Here's the error that appears:

[Image: error-01.png][Image: error-02.png]

Here's the code that I use to generate the rope:
[Image: rope-01.png]
[Image: rope-02.png]

I call the SetupRopeObject method in Awake, then run the CreateRopeRoutine 0.2 seconds later.

Any help would be appreciated! Thanks!
Reply
#2
Any help please?  Triste
Reply
#3
(19-04-2020, 06:22 AM)hecali_aj Wrote: Any help please?  Triste

Hi,

It’s weekend, barely a day since your original post, and i can’t give you an answer off the top of my head for this one. Please be patient, I need to actually run your code and debug it. Will do so asap (probably tomorrow morning) and let you know my findings.

Edit: if you could post your code as text instead of images, it would allow me to copy-paste, saving me from having to rewrite it from scratch.  Ángel

Cheers,
Reply
#4
(19-04-2020, 09:33 AM)josemendez Wrote: Hi,

It’s weekend, barely a day since your original post, and i can’t give you an answer off the top of my head for this one. Please be patient, I need to actually run your code and debug it. Will do so asap (probably tomorrow morning) and let you know my findings.

Edit: if you could post your code as text instead of images, it would allow me to copy-paste, saving me from having to rewrite it from scratch.  Ángel

Cheers,

Hello! Sorry for the bump.

Here's the code:


Code:
    private void Awake()
    {
        SetupRopeObject();
    }

    void Start()
   {
        CreateRope();
    }

    void SetupRopeObject()
    {
        _rope = _ropeTransform.gameObject.AddComponent<ObiRope>();
        _ropeRenderer = _ropeTransform.gameObject.AddComponent<ObiRopeExtrudedRenderer>();
        _ropeRenderer.section = _ropeSection;

        _ropeBlueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
    }

    public void CreateRope()
    {
        if (_ropeEnd == null)
            return;

        StartCoroutine(CreateRopeRoutine());
    }

    IEnumerator CreateRopeRoutine()
    {
        yield return new WaitForSeconds(0.2f);

        _ropeIndex = DataController.RopeIndex;
        DataController.RopeIndex++;

        Vector3 ropeEndPosition = transform.InverseTransformPoint(_ropeEnd.position);

        _ropeBlueprint.path.Clear();
        _ropeBlueprint.path.AddControlPoint(_ropeStart.localPosition, Vector3.zero, Vector3.zero, Vector3.zero, 0.1f, 0.1f, 1, _ropeIndex + 1, Color.white, "start");
        _ropeBlueprint.path.AddControlPoint(ropeEndPosition, Vector3.zero, Vector3.zero, Vector3.zero, 0.1f, 0.1f, 1, _ropeIndex + 1, Color.white, "end");
        _ropeBlueprint.thickness = 0.2f;
        _ropeBlueprint.path.FlushEvents();

        yield return _ropeBlueprint.Generate();

        Debug.Log(_ropeBlueprint.groups[0]);

        ObiParticleAttachment attachment;
        attachment = _rope.gameObject.AddComponent<ObiParticleAttachment>();
        attachment.target = transform;
        attachment.particleGroup = _ropeBlueprint.groups[0];

        attachment = _rope.gameObject.AddComponent<ObiParticleAttachment>();
        attachment.target = _ropeEnd;
        attachment.particleGroup = _ropeBlueprint.groups[1];

        _rope.GetComponent<RopeController>().SetRope(_rope);

        _rope.ropeBlueprint = _ropeBlueprint;
        _rope.GetComponent<MeshRenderer>().enabled = true;

        isRopeCreated = true;
    }

The part that causes the error is this:

Code:
if (particleIndex < m_Actor.solverIndices.Length)

Which is called from the Bind() function here:
Code:
public ObiParticleGroup particleGroup
       {
           get
           {
               return m_ParticleGroup;
           }
            set
            {
                if (value != m_ParticleGroup)
                {
                    Disable(m_AttachmentType);
                    m_ParticleGroup = value;
                    Bind();
                    UpdateEnabledState();
                }
            }
        }
Reply
#5
Sorry for bumping, but it's been 3 weeks and I really need some help on this one.
Reply
#6
(20-05-2020, 06:22 PM)hecali_aj Wrote: Sorry for bumping, but it's been 3 weeks and I really need some help on this one.

Hi!

My apologies for not looking at this earlier, I have a lot of support requests lately.

By looking at the code, I see you’re creating the attachments before assigning the blueprint to the rope. This will most likely result in the attachments trying to attach a particle that does not exist yet, because the blueprint hasn’t been instantiated.

Move both attachments after the rope.ropeBlueprint = _ropeBlueprint; line. That should work.
Reply
#7
(20-05-2020, 08:41 PM)josemendez Wrote: Hi!

My apologies for not looking at this earlier, I have a lot of support requests lately.

By looking at the code, I see you’re creating the attachments before assigning the blueprint to the rope. This will most likely result in the attachments trying to attach a particle that does not exist yet, because the blueprint hasn’t been instantiated.

Move both attachments after the rope.ropeBlueprint = _ropeBlueprint; line. That should work.

It finally worked, thanks for the help!
Reply