public void UpdateLine(Vector3 position) { if (!canDraw) { if (Vector3.Distance(position, _prevRing0) > 0.05f) { return; } else { BeginNewLine(); } } _parent.mParticles.SetActive(false); _smoothedPosition.Update(position, Time.deltaTime); LastTime += Time.deltaTime; if (LastTime <= 0.035f) { return; } _parent.upDateColor(); LastTime = 0; if (length == 0) { firstPosition = position; length = 0.01f; //trending = Vector3 (0f, 0f, 0f); } else { _smoothedPosition.value = _smoothedPosition.value + trending / 2; trending = _smoothedPosition.value - _prevRing0; length += Vector3.Distance(_prevRing0, _smoothedPosition.value); } bool shouldAdd = false; shouldAdd |= _vertices.Count == 0; shouldAdd |= Vector3.Distance(_prevRing0, _smoothedPosition.value) >= _parent._minSegmentLength; if (shouldAdd) { addRing(_smoothedPosition.value); //Add to the path also. _parent.scriptC.addPath(_smoothedPosition.value); updateMesh(); canDraw = true; } }