State and linking issue

Sure I will do that. Thanks again. This is really making me question if I should be learning this… i dont think it should be so frustrating on such a simple thing… however part of me hopes that understanding this fully will help me further down the road… anyways I got to run an errand however will be back in a hour or so to zip that up. Thanks Rob.

Hi Ian,

Try not to let it frustrate you, it’s just a case of hunting down the little bug that this is experiencing. It’s often quite easy to miss a step in the video lectures, especially if you look down to type and then back up and the instructor may have made a minor change in those few moments etc… Let’s see what we can fathom out. The process of debugging is a good skill to learn, no one’s code or project is ever, or will ever be, perfect - so being able to step through and work things out is good :slight_smile:

I’ll jump back on in about an hour then and look for your zip :slight_smile:

Alright now. The adventure of zipping up the files… hmm can i just export it as package or do I need to go through a different means and actually get it in a zip file? If I have to go and zip files up i will… just hoping this can work. here is my exported unity package at this web address :
https://drive.google.com/file/d/1jrEsM6CnT21fP83jUVIc6NUR2ITYxJD6/view?usp=sharing

You probably could export it as a package, but then I will need to create a project at this end, and what I would rather have is exactly the same as you… so, if you could go to the trouble of actually zipping up all of the files that would be better for myself.

They will all invariably be in the same directory.

ohkay

its all stuff i need to get comfortable with

Do I zip up the whole CYOA file?

It’s ok, take your time, I’m around for a wee while longer yet.

Here’s a screenshot of what a little project would look like, e.g. the files…

image

Ignore the path obviously in the address bar at the top, which would be specific to myself, but you can see that the last folder I am in is the name of the project, and then within that I have the assets folder, project settings and so on… so this would, ideally, be the folder to zip for myself.

The whole folder, yeah… so if your project files are in a folder called CYOA then yeah, zip that with all its contents… perfecto!

Its giving me a file not found or no read permission

What’s the path to your project?

Incidentally, I’ve created a new project this end, imported your package, loaded the CYOA scene, run the game and there are no errors.

I am soo confused…

Hold the phone… it’s because your code is still all commented out… lol… hang on, my bad :slight_smile:

Ok, I have found your issue…

At some point you have added your CYOA.cs script to the Main Camera. So, whilst you have dragged the game objects (text component and state) to the CYOA.cs script attached to the Game GameObject, if you look at your Main Camera GameObject, you’ll note that the Text Component isn’t set.

…and, BOOM, there’s the error message regarding the NullReferenceException.

To resolve, remove the CYOA.cs script component from the Main Camera GameObject. :slight_smile:


Updated Mon Aug 20 2018 22:52

Also, check all of your other GameObjects, I’ve just found another CYOA.cs script component on your Canvas too, although it’s disabled, it doesn’t need to be there.

Yah and i couldnt set any text to that one…

alright, so I dont send any script to the camera.

Thanks so much… Only one thing should have my script and thats my Game gameObject… correct?

You can, but that isn’t the issue, the issue is that with the script that is attached, it then has a missing reference, this is what is generating the error.

I suspect in the lectures they are getting you to add the AdventureGame.cs script to the AdventureGame GameObject, there are some slight differences between the projects clearly with naming, but I would follow the instructions with regards to the placement of the scripts, at least for the time being. :slight_smile:

Yah once I started hitting some errors, I started putting it to everything to see if that changed things

In this case, yes. In other cases, there may be scenerios where multiple GameObjects have the same script component attached. If we took for example a Health.cs script which we wanted on 1,000 enemies in the scene, and also the player… in that case, we would want each of them to have a copy of it, because the behaviour would be relevant to each object.

In this specific case you have one text field that you are going to update, so it doesn’t make sense to have multiple GameObjects all telling the same text box to update with the same text several times.

Check, understood. Thanks for walking me through that. Such a relief to get past that small yet very annoying issue.

1 Like

Privacy & Terms