NullReferenceError in Build but not the Editor,NullReferenceException in Build but not Editor.
In the editor when I press play to attack I have to press a key. it will then send out a ray and if it hits the enemy it spawns an object and damages the enemy. But in the build when I press the key I get a NullReferenceException. I am new to Unity so I don't know how to fix this or what the problem is. This is the log when i run the game.,In the editor everything is working fine but when I export it as a standalone build there is an error. The error occurs when I press the for the player to send out a ray. If it hits the enemy an object will spawn and damage will be dealt to the enemy. But in the code when I press the key I just get an error nullreferenceexception. I am new to Unity so I don't know if I am making a stupid mistake or not. This is the log when I run the game:
Begin MonoManager ReloadAssembly - Completed reload, in 1.599 seconds Initializing input.
Input initialized.
Initialized touch support.
Setting up 2 worker threads for Enlighten. Thread -> id: 1580 -> priority: 1 Thread -> id: 2c24 -> priority: 1 UnloadTime: 4.213251 ms Hit A Player UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) PlayerController:NormalAttack1() (at C:\Users\christian\Documents\Deadly Sins\Assets\Scripts\PlayerController.cs:138) PlayerController:Update() (at C:\Users\christian\Documents\Deadly Sins\Assets\Scripts\PlayerController.cs:48)
(Filename: C:/Users/christian/Documents/Deadly Sins/Assets/Scripts/PlayerController.cs Line: 138)
NullReferenceException at (wrapper managed-to-native) UnityEngine.Object:INTERNAL_CALL_Internal_InstantiateSingle (UnityEngine.Object,UnityEngine.Vector3&,UnityEngine.Quaternion&) at UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) [0x00006] in C:\buildslave\unity\build\artifacts\generated\common\runtime\UnityEngineObjectBindings.gen.cs:52 at UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) [0x00022] in C:\buildslave\unity\build\Runtime\Export\UnityEngineObject.cs:155 at UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original, Vector3 position, Quaternion rotation) [0x00009] in C:\buildslave\unity\build\Runtime\Export\UnityEngineObject.cs:205 at PlayerController.NormalAttack1 () [0x000ad] in C:\Users\christian\Documents\Deadly Sins\Assets\Scripts\PlayerController.cs:140 at PlayerController.Update () [0x00095] in C:\Users\christian\Documents\Deadly Sins\Assets\Scripts\PlayerController.cs:48
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObjectBindings.gen.cs Line: 52)
Your answer
Follow this Question
Related Questions
Input Working in Editor but not in Build 0 Answers
Simple game lags while in editor but runs fine when build 1 Answer
Switch Platform happens when Target Platform changed before Switch Platform button press 0 Answers
Why are my textures misaligned in the standalone build? 1 Answer
Why does my shoot script break when I build the game 0 Answers