#nullreference in build

1 messages ยท Page 1 of 1 (latest)

storm ledge
#

i am having an issue with nullreferences in the build and not the editor

#

what is happening is that none of my scripts seem to be able to access anything outside

#

their own gameobject

#

player2
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
generalmovementscript:Start () (at C:/Users/Admin/New Unity Project (2)/Assets/scripts/generalmovementscript.cs:63)

(Filename: C:/Users/Admin/New Unity Project (2)/Assets/scripts/generalmovementscript.cs Line: 63)

NullReferenceException: Object reference not set to an instance of an object
at generalmovementscript.Start () [0x001bc] in C:\Users\Admin\New Unity Project (2)\Assets\scripts\generalmovementscript.cs:104

(Filename: C:/Users/Admin/New Unity Project (2)/Assets/scripts/generalmovementscript.cs Line: 104)

Null
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)

#

is a part of the erro log

wanton patio
#

Use code sharing guidelines for errors and code
!code

somber jewelBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

๐Ÿ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

wanton patio
#

And we don't need all the errors right away. Pick and share one.

storm ledge
#

this is a really small part of all the errors

#

i just wanted to show the two debug log reulsts

#
    {
        Debug.Log(gameObject.tag);
#

hold on

#

where can i find backquotes

#

this is line 61 62 and 63 of generalmovementsscript

#
        Debug.Log(p1);
#

player1
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
generalmovementscript:Start () (at C:/Users/Admin/New Unity Project (2)/Assets/scripts/generalmovementscript.cs:63) oh i forgot that i needed this

wanton patio
#

Take a screenshot of the error and share the whole generalmovementsscript. Upload it to a paste site.

storm ledge
wanton patio
#

Line 63..?
CurrentMove4 = jam;

storm ledge
#

oh wait

#

uhh

wanton patio
#

It feels like your code changes did not compile. The game runs an older code while you keep on making changes that don't apply

storm ledge
#

oh i saw the problem

#

i missed a few lines at the top when positng to that site

night rain
#

after

#

you changed the code

storm ledge
#

this should be the correct code

storm ledge
storm ledge
night rain
storm ledge
#

oh yes i did rebuild it after i changed the code

night rain
#

ok

#

dlich might need to carry i cant put off studying any longer sryy

#

been procrastinating too hard ๐Ÿ˜ฆ

wanton patio
storm ledge
#

yeah it didnt

wanton patio
#

??

#

Was that a stack trace of a log message?

wanton patio
#

Please take a screenshot of one of the errors in the console...

storm ledge
#

there are both errors and normal logs in that text

#

the null is from line38

#

and an error occurs when i try to pull something from it in line49

wanton patio
#
p1 = GameObject.FindWithTag("player1").GetComponent<generalmovementscript>();
Debug.Log(p1);
storm ledge
#

yep that one

wanton patio
#

Try separating that line into 2. One that finds the object with the tag and the other one getting the component. Then debug the name of the found gameobject.

storm ledge
#

oh wow i think i just found the issue

#

it returns a descendant of the object i wanted apparently

wanton patio
#

Yep. It probably has the tag

storm ledge
#

one question though

#

why does it return the parent in the editor but the child in the build

wanton patio