void FixedUpdate() { Vector3 armVector = -attachmentPoint.transform.right; Vector3 headToArmVector = (attachmentPoint.transform.position - head.transform.position).normalized; DebugLineRenderer.Draw(attachmentPoint.transform.position, attachmentPoint.transform.position + armVector, armCurrentlyVisible ? Color.green : Color.red); DebugLineRenderer.Draw(attachmentPoint.transform.position, attachmentPoint.transform.position + headToArmVector, Color.blue); if (armCurrentlyVisible) { if (Vector3.Dot(armVector, headToArmVector) <= lookingAwayFromArmValue && Vector3.Dot(head.transform.forward, -headToArmVector) <= lookingAwayFromArmValue) { return; } tablet.SetActive(false); laser.SetActive(false); armCurrentlyVisible = false; } else { if (Vector3.Dot(armVector, headToArmVector) >= lookingAtArmValue || Vector3.Dot(head.transform.forward, -headToArmVector) >= lookingAtArmValue) { return; } tablet.SetActive(true); laser.SetActive(true); armCurrentlyVisible = true; } }
void FixedUpdate() { if (pathIndex >= 0) { transform.position = Vector3.MoveTowards(transform.position, path[pathIndex].position + new Vector3(0.0f, 0.02f, 0.0f), Time.deltaTime * 2.5f); float distance = Vector3.Distance(transform.position, path[pathIndex].position); if (distance < 1.0f && pathIndex - 1 >= 0) { Quaternion lookOnLook = Quaternion.LookRotation(path[pathIndex - 1].position - transform.position); transform.rotation = Quaternion.Slerp(previousRotation, lookOnLook, 1.0f - distance); } if (distance < 0.05f) { if (pathIndex - 1 >= 0) { previousRotation = Quaternion.LookRotation(path[pathIndex - 1].position - transform.position); } pathIndex--; } } else { Destroy(gameObject); } Node prev = null; for (int i = pathIndex; i >= 0; i--) { DebugLineRenderer.Draw(prev == null ? transform.position : prev.position, path[i].position, Color.green); prev = path[i]; } }