error CS0029: Cannot implicitly convert type 'float' to 'bool'

I know this is your first post but a number of things first:

  • Please Don’t post pointless polls.

  • Please don’t post general scripting issues on the 2D forum. Please use the scripting forum instead.

  • Please post code using code-tags i.e. don’t take screenshots of code because it’s impossible to reference/copy them to refer to them for you.

I’ll move your post for you.

If you have a problem like this then use the API docs. As you would see, Input.GetAxisRaw returns a float value. You are using it in a if condition which requires a bool (true/false). The compiler is telling you that it cannot convert a float value (real number) to a true/false.

If you are following a tutorial, I would check it again. That part of the code is normally a check for a KeyDown which tells you if the key was pressed (true/false) for instance.

2 Likes