public void Probe() { clearGround(); float probeHeight = controller.Position.y + (controller.Radius * 2) + (Mathf.Abs(controller.Velocity.y) * Time.deltaTime); Vector3 o = new Vector3(controller.Position.x, probeHeight, controller.Position.z); DebugDraw.DrawMarker(o, 0.25f, Color.green, 0, false); float smallerRadius = controller.Radius * 0.8f; RaycastHit hit; if (Physics.SphereCast(o, smallerRadius, -controller.Up, out hit, Mathf.Infinity, environmentLayer)) { Vector3 p = MathUtils.MoveTowards(hit.point, controller.Position, controller.Radius); ground = new Ground(hit.point, p, hit.normal, hit.distance, hit.collider.gameObject); DebugDraw.DrawMarker(hit.point, 0.25f, Color.red, 0, false); DebugDraw.DrawMarker(p, 0.25f, Color.blue, 0, false); } }
public static void DrawVector(Vector3 position, Vector3 direction, float raySize, float markerSize, Color color, float duration, bool depthTest = true) { Debug.DrawRay(position, direction * raySize, color, 0, false); DebugDraw.DrawMarker(position + direction * raySize, markerSize, color, 0, false); }