Help us understand the problem. What is going on with this article?


More than 1 year has passed since last update.
void RayTest()
        //Rayの作成       ↓Rayを飛ばす原点   ↓Rayを飛ばす方向
        Ray ray = new Ray (transform.position, new Vector3 (0, -1, 0));

        RaycastHit hit;

        int distance = 10;

        //Rayの可視化    ↓Rayの原点    ↓Rayの方向         ↓Rayの色
        Debug.DrawLine (ray.origin, ray.direction * distance,;

        //                  ↓Ray  ↓Rayが当たったオブジェクト ↓距離
        if (Physics.Raycast(ray,out hit,distance))
                if (hit.collider.tag == "Player")
                Debug.Log ("RayがPlayerに当たった");
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away