Created
March 14, 2025 16:34
-
-
Save Velsimir/b94e009520e8b6cd9e973a40b9acf7d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HighClimber : MonoBehaviour | |
| { | |
| [SerializeField] private float _stepHeight = 0.3f; | |
| [SerializeField] private float _slopeLimit = 45f; | |
| private Bot _bot; | |
| private float _stepCheckDistance = 0.5f; | |
| private float _colliderRadius = 0.3f; | |
| public void Initialize(Bot bot) | |
| { | |
| _bot = bot; | |
| } | |
| private void FixedUpdate() | |
| { | |
| CheckStep(); | |
| } | |
| private void CheckStep() | |
| { | |
| Vector3 rayOrigin = transform.position + Vector3.forward / 2; | |
| if (Physics.SphereCast(rayOrigin, _colliderRadius, Vector3.down / 2, out RaycastHit hit)) | |
| { | |
| float obstacleHeight = hit.point.y - transform.position.y; | |
| if (obstacleHeight <= _stepHeight) | |
| { | |
| Debug.Log("Может пройти"); | |
| } | |
| else | |
| { | |
| Debug.Log("Не может пройти"); | |
| } | |
| } | |
| } | |
| private void OnDrawGizmos() | |
| { | |
| Gizmos.color = Color.red; | |
| Gizmos.DrawWireSphere(transform.position + Vector3.forward / 2 + Vector3.down, 0.3f); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment