我的脚本附加到角色控制器。
我宣布,
public Camera camera;
在班上。在我给出的更新函数中,
if(Input.GetMouseButtonDown(0)){
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray, out hit3, 400.0F)){
print(hit3.collider.gameObject.name);
}
}
但我收到错误
"UnassignedReferenceException:
The variable camera of 'characterScript' has not been assigned.
You probably need to assign the camera variable of the
characterScript script in the inspector."
帮我一个好的解决方案。
提前致谢。