“Unity 2D Raycast Mouse” Kode Jawaban

Unity 2D Raycast Mouse

// detect object that was clicked using raycast

RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
 
if(hit.collider != null)
{
    Debug.Log ("Target name: " + hit.collider.name);
}
Ori6151

Unity Raycast 2d

Physics2D.Raycast(Vector2 origin, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity);
Mage

Jawaban yang mirip dengan “Unity 2D Raycast Mouse”

Pertanyaan yang mirip dengan “Unity 2D Raycast Mouse”

Lebih banyak jawaban terkait untuk “Unity 2D Raycast Mouse” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya