unity 2d array code example Example: 2d ray unity RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up);