I Need help with scripting a first person camera?
This is my code I am using to get the camera to follow the mouse and where it points to (so it can be a first-person game) but it keeps coming up with the error message. Just so you know I am new to Unity, so I found a tutorial on youtube on how to accomplish this but it isn't working. So if anyone can help me out and knows how to fix this error message that would be greatly appreciated!
Assets/camMouseLook.cs(13,18): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification
Answer by MacDx · Dec 18, 2017 at 11:35 PM
The error you are getting is pretty explicit. Expression bodied members cannot be used because it is not part of the C# 4.0 language specifications. This means that Unity is using C#4.0 and you are trying to use a language feature that was introduced in a later C# version.
You have 2 options here: Get rid of the expression bodied member and write a normal method body, just like you did with your Update. In my opinion this makes the most sense since expression bodied members are used by convention for short (usually one liners), repetitive methods. Start in your case is only one line, but it might grow bigger later in your project, and you don't do the same thing in every start since every behaviour needs a different initialization.
The other option is to enable C#6 by switching the Scripting Runtime Version configuration from .NET 3.5 to .NET 4.6. This should allow for C#6 syntax which should include expression bodied methods (Unity 2017 is needed for this).
Edit: You can find Scripting Runtime Version in Player Settings, Other Settings Tab, Configuration Section. To open Player Settings you can do File>Build Settings> Player Settings, or Edit>Project Settings>Player
Hope this helps!
Thank you so much! This has really helped me! Now that i got the game to run it's not following the mouse movement got any ideas on why that could be?
Your answer
Follow this Question
Related Questions
Please Help Me: Assets/Scripts/PlayerControaller.cs(34,33): error CS8025: Parsing error 1 Answer
cannot convert type HealthandInventory to int 0 Answers
How to setactive Car Script on writing script on Java on Android platform 0 Answers
How do I fix "universul?" script problem 0 Answers
Object reference not set to an instance of an object - Jumping Scripts (C#) 1 Answer