void Shoot() { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "Target") { // Hide indication and hide crosshair for half a second m_HUD.DisplayTexture(0); StartCoroutine(BlindCrosshair()); // Re-lock targets so there can only be one shoot m_targetManager.LockTargets(); // Get info string targetName = hit.transform.parent.name; m_impactGameobject.transform.position = hit.point; m_impactGameobject.transform.parent = hit.transform; Vector3 localResult = m_impactGameobject.transform.localPosition; Vector3 targetSize = hit.transform.gameObject.GetComponent <MeshFilter>().mesh.bounds.size; Vector3 results = new Vector3(Mathf.Abs((2f * localResult.x) / targetSize.x), 0f, Mathf.Abs((2f * localResult.z) / targetSize.z)); // Output info in .txt file if (m_outputWriter.GetRecord()) { m_outputWriter.AddRelativeResults(targetName, results, m_timer.Lap()); } // Launch next step or stop and reset timer StopAllCoroutines(); if (m_playSequenceManager.GetLastIteration()) { // Sequence ending m_timer.Stop(); m_timer.Reset(); m_outputWriter.StandardExit(); // Thumbs up ! StartCoroutine(ThumbsUp(m_playSequenceManager.GetTemporisationTime())); m_playSequenceManager.SetIsRunning(false); } else { StartCoroutine(m_playSequenceManager.NextStep()); } } } }
void Shoot() { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "Target") { // Hide indication m_HUD.DisplayTexture(0); // Re-lock targets so there can only be one shoot m_targetManager.LockTargets(); // Get info string targetName = hit.transform.parent.name; Vector3 targetCenter = hit.transform.position; Vector3 targetSize = hit.transform.gameObject.GetComponent <MeshFilter>().mesh.bounds.size; Vector3 targetScale = hit.transform.lossyScale; Quaternion targetRotation = hit.transform.rotation; //Vector3 results = m_matrixCalculation.ComputeResult(hit, MatrixCalculation.ComputationMethod.Euler); Vector3 results = m_matrixCalculation.ComputeResult(hit, MatrixCalculation.ComputationMethod.Quaternion); // Output info in .txt file if (m_outputWriter.GetRecord()) { //m_outputWriter.AddTrialResults(targetName, targetCenter, targetRotation, targetSize, targetScale, hit.point, m_timer.Lap()); m_outputWriter.AddRelativeResults(targetName, results, m_timer.Lap()); } // Launch next step or stop and reset timer StopAllCoroutines(); if (m_playSequenceManager.GetLastIteration()) { // Sequence ending m_timer.Stop(); m_timer.Reset(); m_playSequenceManager.SetIsRunning(false); // Thumbs up ? } else { StartCoroutine(m_playSequenceManager.NextStep()); } } } }