I am new to Unity and I need help with Javascript maybe C#

I have been looking at tutorials and i know kind of the basics of Unity Javascript. Like
var var: boolean=true
function start ()
{
if (var=true)
print (“Hi”)
else
print (“bye”)

I know that is really basic and I may have got some of the syntax wrong but i need help learning unity javascript. What should I do. And should I just go to C# instead. Is it any better for a beginner to try.

Please help :o

For what i’m guessing is that you are a true beginner with programming?

If this is the case, I would suggest you stick to JavaScript since most of these tutorials are in that language.

follow the 3rd person tutorial and the side scrolling. it explains some of the code that you will be using.

Also, don’t be afraid to search the web for the syntax. (always use the key word unity if you aren’t looking in the unity ages because there’s allot of external sites that will give you code example for building up a game. this site for example: Crazy Creative)

Other then that, there’s no magic solution and you will learn by trial and error.

it will be frustrating at some point and but the reward at the end of the line will be worth it.

javascript is easier to learn imo, especially because most of the tutorials here are written in javascript. you should really work through all the tutorials on this site, it’s the best way to learn unity. after that you can check if you understood everything by making a simple game yourself (pong for example)

I personally favor C# (although the syntax is very similar) but because you are new to Unity (and a first post! :slight_smile: ) I’d say learn your javascript as it seems most of the Unity example projects are backed by js and not C#.

A few points to your code snippet:

var var: boolean=true

// don't name variables with keywords ("var")
// aside from probable compiler errors/warnings you'd get,
// remember that you can name variables as you like, so make them
// descriptive as to their purpose in life like this:
//
// var hasLevelLoaded : boolean

function start ()
{
if (hasLevelLoaded=true)

// what you are doing here is setting hasLevelLoaded
// to true, not evaluating it to see IF it is true
// So what you want there is as follows; the spaces
// are not required, the double == operator is, however
//
// if (hasLevelLoaded == true)
//
// or even better:
//
// if (hasLevelLoaded)
//     print("Level loaded!");
//
// and note the closing semi-colon -- you are missing
// those on the print calls as well:

print ("Hi")
else
print ("bye")
}

Good luck with the learning; this forum along with the UnityAnswers site will definitely help you along.