Skip to content

Instantly share code, notes, and snippets.

@nopitech
Created May 7, 2019 13:37
Show Gist options
  • Save nopitech/7fae40b0bc8a1e8282416bc27c307cd6 to your computer and use it in GitHub Desktop.
Save nopitech/7fae40b0bc8a1e8282416bc27c307cd6 to your computer and use it in GitHub Desktop.
RaycastHit hit;
void Update()
{
Ray ray = new Ray(transform.position, transform.TransformDirection(Vector3.up));
// レイ飛ばす
if (Physics.SphereCast(ray, 1f, out hit, 100f))
{
Debug.Log(hit.collider.gameObject.name);
}
}
// 表示(シーンビューのみ)
void OnDrawGizmosSelected()
{
Gizmos.DrawWireSphere(hit.point, 1f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment