28-04-2020, 12:24 PM
(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();
}
}
}