Posts: 16
Threads: 9
Joined: Nov 2018
Reputation:
0
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:
Here's the code that I use to generate the rope:
I call the SetupRopeObject method in Awake, then run the CreateRopeRoutine 0.2 seconds later.
Any help would be appreciated! Thanks!
Posts: 16
Threads: 9
Joined: Nov 2018
Reputation:
0
Any help please?
Posts: 6,313
Threads: 24
Joined: Jun 2017
Reputation:
399
Obi Owner:
19-04-2020, 09:33 AM
(This post was last modified: 19-04-2020, 10:14 AM by josemendez.)
(19-04-2020, 06:22 AM)hecali_aj Wrote: Any help please?
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.
Cheers,
Posts: 16
Threads: 9
Joined: Nov 2018
Reputation:
0
(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.
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();
}
}
}
Posts: 16
Threads: 9
Joined: Nov 2018
Reputation:
0
Sorry for bumping, but it's been 3 weeks and I really need some help on this one.
Posts: 6,313
Threads: 24
Joined: Jun 2017
Reputation:
399
Obi Owner:
(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.
Posts: 16
Threads: 9
Joined: Nov 2018
Reputation:
0
(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!
|