void Update() { if (properties == null) { return; } RaycastHit raycastHit; if (!Physics.Raycast(transform.position, Vector3.down, out raycastHit, 10)) { return; } Vector3 p = raycastHit.point; Debug.DrawLine(transform.position, p, Color.red); //Debuger_K.ClearGeneric(); RaycastHitNavMesh raycastHitNavMesh; for (int i = 0; i < tests; i++) { float x = Mathf.Cos((i / (float)tests) * 2 * Mathf.PI); float z = Mathf.Sin((i / (float)tests) * 2 * Mathf.PI); //var q = Quaternion.LookRotation(transform.forward + new Vector3(x, 0, z), Vector3.up); PathFinder.Raycast(p, new Vector3(x, 0, z), properties, out raycastHitNavMesh); if (raycastHitNavMesh.isOnGraph) { Debuger_K.AddLine(p, raycastHitNavMesh.point, Color.blue); Debuger_K.AddLabel(raycastHitNavMesh.point, "H"); } } //PathFinder.Raycast(p, transform.forward * -1, properties, out raycastHitNavMesh); //if (raycastHitNavMesh.isOnGraph) { // Debuger_K.AddLine(p, raycastHitNavMesh.point, Color.blue); // Debuger_K.AddLabel(raycastHitNavMesh.point, "B"); //} //PathFinder.Raycast(p, transform.transform.right * -1, properties, out raycastHitNavMesh); //if (raycastHitNavMesh.isOnGraph) { // Debuger_K.AddLine(p, raycastHitNavMesh.point, Color.blue); // Debuger_K.AddLabel(raycastHitNavMesh.point, "L"); //} //PathFinder.Raycast(p, transform.right, properties, out raycastHitNavMesh); //if (raycastHitNavMesh.isOnGraph) { // Debuger_K.AddLine(p, raycastHitNavMesh.point, Color.blue); // Debuger_K.AddLabel(raycastHitNavMesh.point, "R"); //} }
void Update() { if (properties == null) { Debug.LogWarning("no properties"); return; } RaycastHit raycastHit; if (!Physics.Raycast(transform.position, Vector3.down, out raycastHit, 10)) { Debug.LogWarning("no raycast hit"); return; } Vector3 p = raycastHit.point; Debug.DrawLine(transform.position, p, Color.red); Debuger_K.ClearGeneric(); //PathFinder.Raycast2(p, new Vector3(forward.x, 0, forward.z), properties); foreach (var d in dataList) { if (d.enabled) { RaycastHitNavMesh2 hit; PathFinder.Raycast(d.position, d.direction, properties, out hit); DrawLine(d.position, hit); } } if (doForward) { RaycastHitNavMesh2 hit; PathFinder.Raycast(p, transform.forward, range, properties, out hit); DrawLine(p, hit); } if (tests > 0) { if (testDirections == null) { testDirections = new Vector2[0]; } if (testDirections.Length != tests) { testDirections = new Vector2[tests]; for (int i = 0; i < tests; i++) { float x = Mathf.Cos((i / (float)tests) * 2 * Mathf.PI); float z = Mathf.Sin((i / (float)tests) * 2 * Mathf.PI); testDirections[i] = new Vector2(x, z); } } PathFinder.Raycast(p.x, p.y, p.z, testDirections, properties, range, ref hits); for (int i = 0; i < hits.Length; i++) { DrawLine(p, hits[i]); } } if (doForward | tests > 0) { for (int i = 0; i < circleThings - 1; i++) { Debug.DrawLine(p + (circle[i] * range), p + (circle[i + 1] * range), Color.blue); } Debug.DrawLine(p + (circle[circleThings - 1] * range), p + (circle[0] * range), Color.blue); } //RaycastHitNavMesh raycastHitNavMesh; //for (int i = 0; i < tests; i++) { // float x = Mathf.Cos((i / (float)tests) * 2 * Mathf.PI); // float z = Mathf.Sin((i / (float)tests) * 2 * Mathf.PI); // //var q = Quaternion.LookRotation(transform.forward + new Vector3(x, 0, z), Vector3.up); // //if (PathFinder.Raycast(p, new Vector3(x, 0, z), properties, out raycastHitNavMesh) && raycastHitNavMesh.resultType != NavmeshRaycastResultType.OutsideGraph) { // // Debuger_K.AddLine(p, raycastHitNavMesh.point, Color.blue); // // Debuger_K.AddLabel(raycastHitNavMesh.point, "H"); // //} // PathFinder.Raycast2(p, new Vector3(x, 0, z), properties); //} }