Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

Arsenii Kovsh
Arsenii Kovsh
537 Points

Several Errors in Unity. This errors doesn't allow me to "Run" the game.

Red Errors: 1) <RI.Hid> Failed to create device file: 2 The system cannot find the file specified. 2) Assets/Scripts/PlayerMovement.cs(22,49): error CS0103: The name `movementVertical' does not exist in the current context

Yellow errors: 1) Assets/Standard Assets/Utility/SimpleActivatorMenu.cs(10,16): warning CS0618: UnityEngine.GUIText' is obsolete:This component is part of the legacy UI system and will be removed in a future release.' 2) Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs(48,37): warning CS0618: UnityEditor.EditorUserBuildSettings.activeBuildTargetChanged' is obsolete:UnityEditor.activeBuildTargetChanged has been deprecated.Use UnityEditor.Build.IActiveBuildTargetChanged instead.' 3) Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs(55,37): warning CS0618: UnityEditor.EditorUserBuildSettings.activeBuildTargetChanged' is obsolete:UnityEditor.activeBuildTargetChanged has been deprecated.Use UnityEditor.Build.IActiveBuildTargetChanged instead.' 4) Assets/Standard Assets/Utility/ForcedReset.cs(6,27): warning CS0618: UnityEngine.GUITexture' is obsolete:This component is part of the legacy UI system and will be removed in a future release.' 5) Assets/Standard Assets/Utility/PlatformSpecificContent.cs(37,37): warning CS0618: UnityEditor.EditorUserBuildSettings.activeBuildTargetChanged' is obsolete:UnityEditor.activeBuildTargetChanged has been deprecated.Use UnityEditor.Build.IActiveBuildTargetChanged instead.' 6) Assets/Standard Assets/Utility/PlatformSpecificContent.cs(44,37): warning CS0618: UnityEditor.EditorUserBuildSettings.activeBuildTargetChanged' is obsolete:UnityEditor.activeBuildTargetChanged has been deprecated.Use UnityEditor.Build.IActiveBuildTargetChanged instead.'

I presume that only Red ones doesn't allow me to Run the game. However it is good to know why I got all of this errors and how should I fix them.

Arsenii Kovsh
Arsenii Kovsh
537 Points

UPD. Solved the Red ones by: Checking the code & clearing mistakes. Removing a game controller from USB port.

1 Answer

I see you solved your problem (only the red errors prevent your game from running), but I'm still gonna tell you what error is what, and hopefully, it will help you.

So first of all: Red errors are critical errors, meaning that the game cannot run when there are some. Yellow errors are warning; the script can - most of the time - work fully even with them, it is generally minor things such as a variable that is declared but never used.

Secondly, you can see where the errors occurred following the path. For example, PlayerMovement.cs(22,49) means that the error occurred in the PlayerMouvement script, at the 22nd line. The error was detected at the 22nd line, so it can't be at that line or it can be a semicolon you forgot the line before.

Red:

2) You are using a variable that doesn't exist in that context. Either you didn't declare it, or you declared it in a sub-context. For example, if you declared that variable inside an if statement and you try to use it outside, it won't work because the variable will be destroyed at the end of the statement.

Yellow:

1) A method you are using will be removed or replaced in a planned update, meaning your game might not work properly after the release.

2) When you don't fix the first warning. The method you are using has been tweaked or removed. A simple way to fix this is to make a backup of your project and run the Automatic API Updater. Here's a link: https://docs.unity3d.com/Manual/APIUpdater.html

I had no idea what the first critical error was, and all of the other warnings are clones of the first 2. Hope this helps!

Arsenii Kovsh
Arsenii Kovsh
537 Points

Thank you very much for explanation! Now it will be easier to deal with such things. The first Red problem occurred, because I have a Controller device in USB drive. I think as there is nothing to support Controller, the problem occurred. Removing it from USB solved the problem.

That's nice to know, I'll check this if I ever get this error.

Also, thanks for the vote :D