LoginSignup
2
0

More than 5 years have passed since last update.

レイキャストを使用した3D射撃スマホゲームの開発

Posted at

動作環境

Unity 2018.2.9f1 Personal

Raycast関数の使い方

Raycastの呼び出し方

Physics.Raycast(Vector3 origin,Vector3 direction,out RaycastHit hitInfo, float distance, int LayerMask);

引数の概要

  1. origin: Rayの始点の座標
  2. direction: Rayの方向
  3. hitInfo: ヒットしたオブジェクトの情報
  4. distance(オプション): Rayの距離(default=Infinity)
  5. LayerMask(オプション): 指定したLayerのオブジェクトに特別な処理をさせる。(例: コリジョン判定を無視するなど)

Tip

第1引数及び第2引数を下記のように纏めて変数に格納し、代入する方法もあるよう。
Ray myRay = new Ray(Vector3 origin, Vector3 direction);
myRay = (始点となるオブジェクトのPosition)
Physics.Raycast(myRay,out RaycastHit hitInfo, float distance, int Layer Mask);

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0