Public and private on Roll a ball project

Hello

My questions is what’s the difference and purpose of public and private on the script “Player”, in the
project “Roll a Ball” tutorial?

Waiting for your help.

Best regards

Perhaps this might help: Access Modifiers - C# reference | Microsoft Learn

Hi all,

I am very new to unity, only my second day using it and new to coding in general. I like to ask a couple of questions please ?, I m following the basic Tutorials on unity and got to one called Roll a Ball. First it very difficult to see the main part when the gentleman is putting in numbers I have to use a magnifying glass to see it, also his version of unity seem a lot different to mine ? whilst doing Roll A Ball we have use a TEXT UI which i did then we have change the position of the text using Anchore which requires me to change numbers when I do this all the text Disappears and I cannot find even when I left that ? Could please help but keep it simple as know nothing about unity yet… Thanks for your time

PS I am Dyslexic so sorry for spelling mistakes

Probably would have been better to start your own post. I haven’t looked at the tutorial, but check your video quality settings. If you lose something in your scene, you can double click it in the hierarchy to bring your camera to it.

1 Like

Thanks though I have started a new post sorry post in your thread, need to learn how to post no easy way of doing that like “Post A new Post”…lots to learn thankyou

At the bottom of every forum section there is a button like this. Click it to create a new thread.

3388913--266402--PostNewThread.png

Sorry, but i still didn’t understand the difference between public and private in that script on that tutorial.
Thanks for the help by the way

There are many reasons why you would make something private / public, however, the most basic ones are probably 2 in a basics tutorial (I didn’t see the tutorial myself, but I’m guessing it will be one of these 2 things).

1 - Private = the variable will only be accessed in the script where it is declared.
2 - Public = a) the variable will be called from some other script / b) the variable’s value will be set from the inspector. If you make variables like ints / strings / others… public, unless you hide them, they will show on your script in the inspector, so you can set their values from the editor, allowing you to change values even at runtime instead of writing them in code.

As I said, it’s a more complicated topic, but for a simple use, I think that should summarize the first differences you will face.

Public can be use in interpreter by change a value and private can only be changed in a that Script and no where else, Hope that help out…Enjoy :slight_smile:

@Trytus58 : Have you been able to solve your issues with the tutorial?

Sorry for this thread ‘merge’… if you’re still stuck, please create a thread and someone will try to help :slight_smile:
Otherwise, if you’ve solved it, that’s great.

Yes Thanks solved the problem with that tutorial now. Still finding this engine very hard to use and when I posted the admin took down my post…nice welcome :(. Just have keep trying and thank you for time
Take care

Another question, i heard that is usefull for login with password. Can you show me a script example?
And is there any other applications besides this one i said?

Sorry, I don’t understand the question(s)?

I heard that if it’s used “private” it’s usefull for login with password.
And i wanted a script example, if you know.
And other applications to use “private”.

I don’t think you should associate private with login and password.
private just means it can only be accessed within the class.

Try this: Scope and Access Modifiers - Unity Learn