// Update is called once per frame void Update() { float tipHeight = transform.Find("Tip").transform.localScale.y; Vector3 tip = transform.Find("Tip").transform.position; //Debug.Log (tip); // Check for a Raycast from the tip of the pen if (Physics.Raycast(tip, transform.up, out touch, tipHeight * 2)) { if (!(touch.collider.CompareTag("DrawingSupport"))) { //Debug.Log(touch.collider.tag); return; } //Debug.Log("Touching !!!"); drawingSupport = touch.collider.GetComponent <DrawingSupport>(); drawingSupport.SetColor(_renderer.material.color); drawingSupport.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y); drawingSupport.ToggleTouch(true); // Give haptic feedback when touching the whiteboard VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 0.05f); // If we started touching, get the current angle of the pen if (lastTouch == false) { lastTouch = true; //lastAngle = transform.rotation; } else { lastTouch = false; drawingSupport.ToggleTouch(false); } } // Lock the rotation of the pen if "touching" /*if (lastTouch) { * transform.rotation = lastAngle; * }*/ }