Errors

Hello guys i try to learn how to use the mouse and i have these errors but the game when i hit play is playing well and i even built it and still working

Your Exp script, line 6, initializes a field called “mouse” to Input.mousePosition. Don’t do that. As the errors point out, this is not a legal thing to do.

1 Like

then how i can strore in a variable the mouse potision

You just assign it later, in Start or Awake for example.

1 Like

Do you need to have access to the position the mouse was at when you clicked a button? If not then I wouldn’t waste time storing it in a variable. I would just use Input.mousePosition.x and Input.mousePosition.y directly in the if-statement.

If you do need to know where the mouse was when the player clicked the button then you’ll need to move the code that sets the variable down into the Update method.

1 Like