How to access variable from another script in Unity?

5c9b84fe6ee23320186090.jpeg
How to get the value of a variable in the script clickedIs carPhysic. I'm new to unity, please help!
March 19th 20 at 08:52
1 answer
March 19th 20 at 08:54
Solution
Unity there is almost nothing to do with it - this is knowledge of c#. You need to carPhysic was a reference to an instance of the class ClickScript from which to get values.

As there will be this link - a lot of options - for example SerializeField.

Code won't write - or don't learn anything.
5c9b8ab2875a7948629037.jpeg
He is the principle red highlights! - Kameron.Leannon commented on March 19th 20 at 08:57
@Kameron.Leannon, it can even purple to highlight what the compiler says? Error? - dwight_Flatl commented on March 19th 20 at 09:00
An object reference is required to access non static member `ClickScript.clickedIs'
He wrote to me when I'm trying to do
Debug.Log(ClickScript.clickedIs); - Kameron.Leannon commented on March 19th 20 at 09:03
Why?Because in the code public?
public bool clickedIs = false; - Kameron.Leannon commented on March 19th 20 at 09:06
Because LEARN WITH#! You have clearly written - it is wrong to refer to a nonstatic method. I clearly wrote - you need an instance of the class.
At least read a couple of books about programming and about the language before you write games. - dwight_Flatl commented on March 19th 20 at 09:09

Find more questions by tags Unity Game EngineDevelopment of games