// Update is called once per frame void Update() { if (!canDraw) { return; } angle = Mathf.Abs(upperHandle.GetRotation() - upperRotation); angle = Mathf.Abs((angle + 180) % 360 - 180); if ((angle > 80f && !mouse && !drawing) || (Input.GetMouseButtonDown(0) && mouse)) { upperRotation = upperHandle.GetRotation(); angle = upperHandle.GetRotation() - upperRotation; angle = Mathf.Abs((angle + 180) % 360 - 180); CreateLine(); drawing = true; audio.drawingSound(); } if ((angle < 30f && !mouse && drawing) || (Input.GetMouseButton(0) && mouse)) { Vector3 tempFingerPos = upperHandle.HandlePosition(transform.position); tempFingerPos.y = .1f; Vector3 latestPos = fingerPositions[fingerPositions.Count - 1]; latestPos.y = .1f; if (Vector3.Distance(tempFingerPos, latestPos) > .1f) { UpdateLine(lineRenderer, tempFingerPos); } } else { if (drawing) { string lineName = "line" + lineCount; Vector3[] linePos = new Vector3[lineRenderer.positionCount]; lineRenderer.GetPositions(linePos); lineRenderer.SetPositions(Curver.MakeSmoothCurve(linePos, .5f)); lines.Add(lineName, lineRenderer); lineRenderer.name = lineName; GameObject.Find("Panto").GetComponent <GameManager>().AddVoiceCommand((lineCount + 1) + "", () => { TraceLine(lines[lineName]); }); lineCount++; drawing = false; audio.stopSound(); } } }
// Start is called before the first frame update void Start() { upperHandle = GameObject.Find("Panto").GetComponent <UpperHandle>(); lowerHandle = GameObject.Find("Panto").GetComponent <LowerHandle>(); upperRotation = upperHandle.GetRotation(); gameManager = GameObject.Find("Panto").GetComponent <GameManager>(); audio = GameObject.Find("Panto").GetComponent <Audio>(); }