Trouble with PlayerController Script

Hello,

I’m trying to follow though a book with a 2D project. The book is called “Learning 2D Game Development with Unity” and I am having a most difficult time. My current issue is with a script for moving the player. I am only partially done with it but at this point the book says I should be able to move horizontally but I get errors in the script. I have checked it 3 times against what the book says and I am confident I typed it in correctly. I am coming here to confirm my suspicions that the author of this book was wrong when he coded this script. The errors I am getting all seem to focus on the use of the void function “Flip” on line 45. It says I can not use void in this context and right after that I am getting an unexpected symbol error for using the “(” symbol.

I attached the script in a text file. Any help would be appreciated

2283198–153293–Script With Error.txt (1.1 KB)

the Flip function shouldn’t be inside FixedUpdate function

So I need to move it out of the FixedUpdate function and then add a declaration since there was not one specified in the book right?

Is my declaration wrong? I am down to a single error and it must be my declaration on line 3 now. If I can solve this I should be golden!

2283243–153296–Script With Error.txt (1.33 KB)

I scraped the entire script they gave me in the book and went with the one attached. Now I can move left and right so i just need to add the jump part and I should be good. If anyone has a better 2D platformer player controller script, I would love to see it and add it to the script collection I am starting.

2283357–153304–Script With Error.txt (607 Bytes)