I'm trying to Add raycast shooting to my player but when I get the Vector2 mouse position it give this error
NullReferenceException: Object reference not set to an instance of an object
This is my code
Vector2 mousePosition =
new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x,
Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
How can i fix this ?