Camera.main is null when performing raycast

后端 未结 2 1551
独厮守ぢ
独厮守ぢ 2020-11-28 16:03

Code that generates an error:

void Update()
{
    if (Input.touchCount > 0)
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPo         


        
2条回答
  •  一生所求
    2020-11-28 16:20

    Make sure you have in your scene an active gameobject with the Camera component and the tag "MainCamera"

    Tag

提交回复
热议问题