Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector3 PerimeterCheck (Transform thisCarsTransform, Collider thisCarsCollider) {
- if (Physics.CheckSphere (thisCarsTransform.position, detectionRadius)) {
- Ray forwardRay = new Ray(thisCarsTransform.position, thisCarsTransform.forward);
- var hits = Physics.SphereCastAll(forwardRay, detectionRadius, detectionRadius);
- foreach (var hit in hits) {
- if (hit.collider != thisCarsCollider) {
- if (hit.transform.tag == "Player" || hit.transform.tag == "Car" || hit.transform.tag == "Boundary") {
- // Red = from origin to point
- Debug.DrawLine(forwardRay.origin, hit.point, Color.red);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement