Hola! espero que esten bien.
Bueno, estube dandole vueltas y vueltas a los RayCast y todabia nose manejarlos bien, es decir, entiendo toda su mecanica a la perfeccion, pero en le codigo me hace cosas raras... y la verdad que me frustra bastante estos raycastsitos....
Bueno la cuestion es que necesito simplificar este despelote asqueroso, o nose si es asqueroso, por ahi es la unica forma de hacerlo, pero miren...
public bool castHitForward;
public bool castHitBack;
public bool castHitLeft;
public bool castHitRight;
private void Update() {
RaycastHit hitForward;
RaycastHit hitBack;
RaycastHit hitLeft;
RaycastHit hitRight;
castHitForward = Physics.Raycast(new Ray(transform.position, Vector3.forward), out hitForward, 0.2f);
castHitBack = Physics.Raycast(new Ray(transform.position, Vector3.back), out hitBack, 0.2f);
castHitRight = Physics.Raycast(new Ray(transform.position,Vector3.right), out hitRight,0.2f);
castHitLeft = Physics.Raycast(new Ray(transform.position, Vector3.left), out hitLeft, 0.2f);
if (castHitForward)
Debug.Log(hitForward.collider.name);
if (castHitBack)
Debug.Log(hitBack.collider.name);
if (castHitRight)
Debug.Log(hitRight.collider.name);
if (castHitLeft)
Debug.Log(hitLeft.collider.name);
}
private void OnDrawGizmos(){
Gizmos.DrawRay(transform.position, Vector3.forward * 0.2f);
Gizmos.DrawRay(transform.position, Vector3