Jump to content

iI am getting into Unity 4 development and was wondering where to learn UnityScript properly. Now I know JavaScript, fairly well, I wouldn't say I'm anything spectacular but I will say I am very good at it. I was wondering about the changes from UnityScript and JavaScript, such as all the functions and inputs I would need to learn. So far I know extremely basic key inputs but I cant get my head around the rest. So I would try and do an if statement but It wouldn't go too well. Not to copy all my script I will show what I did.

 

var isJumping : boolean = false

 

if (isJumping == false) {

   (this is where I put my basic movement script)

}

else if (isJumping == true) {

   (The movement script, same as before, but with no function from the jump button being pressed as I didn't want a double jump ingame)

}

 

Errors came up about my variables and "if" statements; "Did i mean ... instead of "boolean"" or whatever. Also saying my if statements were incorrect. Now I started with going "===" instead of "==" because, y'know, that's how it is in JS, then I saw it is "==" in UnityScript. I just really want to learn UnityScript from a good source, not some terrible video from YouTube with someone who has no clues what the functions are doing it in US, giving up and then doing it in C# instead.

 

Thank you in advance.

Link to comment
https://linustechtips.com/topic/291986-unityscript/
Share on other sites

Link to post
Share on other sites

Now I know JavaScript, fairly well, 

 

Not having worked with Unity I am not entirely sure meself, but I heard that UnityScript should be fairly similar to JavaScript.

 

 

EDIT:

Syntax from their website:

 

if(coffeeTemperature > hotLimitTemperature){// ... do this.print("Coffee is too hot.");}// If it isn't, but the coffee temperature is less than the coldest drinking temperature...else if(coffeeTemperature < coldLimitTemperature){// ... do this.print("Coffee is too cold.");}// If it is neither of those then...else{// ... do this.print("Coffee is just right.");}

DayZ Forum Moderator, DayZ Developer, ARMA 3: 2017 Developer, System-Admin, Gameserver-Admin, always interested to learn something new as well as new people.

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3965852
Share on other sites

Link to post
Share on other sites

Not having worked with Unity I am not entirely sure meself, but I heard that UnityScript should be fairly similar to JavaScript.

It is but I just don't know the language differences there are. Kind of like the functions needed. So US has such things like "GetAxis"and all that jazz, whatever the name of it is called I believe functions but the proper term I have no clue what it is. Any websites where there is good tutorials on UnityScript would help, I just need to get my head around all the properties.

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3965890
Share on other sites

Link to post
Share on other sites

http://docs.unity3d.com/ScriptReference/

Here you can find some stuff (JS should be the default website language)

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3965974
Share on other sites

Link to post
Share on other sites

If you know how to program you should just download some example projects and read the scripts.

From m experience unity example projects scripts are well documented and you will learn alot just by reading.

 

When I learned how to program in unity I just started programming some scripts and used the scripting reffernce for thing I didn't know.

Use the unity forum if you get in to problems, they helped so much hen i just started few years back.

 

If you need help with your first script I will love to help you.

 

Good luck.

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3967151
Share on other sites

Link to post
Share on other sites

I don't bother the js(unity script), C# is the best option or use Boo if you like simple syntax.

I'm Batman!

Steam: Rukiri89 | uPlay: Rukiri89 | Origin: XxRukiriXx | Xbox LIVE: XxRUKIRIxX89 | PSN: Ericks1989 | Nintendo Network ID: Rukiri

Project Xenos: Motherboard: MSI Z170a M9 ACK | CPU: i7 6700k | Ram: G.Skil TridentZ 16GB 3000mhz | PSU: EVGA SuperNova 850w G2 | Case: Caselabs SMA8 | Cooling: Custom Loop | Still in progress 

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3967347
Share on other sites

Link to post
Share on other sites

Btw you shouldt use if (myBoolean == true) or if (myBoolean == false).

You should use:

 

if (myBoolean) {

//Means boolean is true

}

 

or

 

if (!myBoolean) {

// Means Boolean is false

}

 

myBoolean stands for "true". So if you write myBoolean == true youre basically writing if (true == true) which returns true. See what i mean :D

It also makes the code a bit easier to read :D

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3982885
Share on other sites

Link to post
Share on other sites

Btw you shouldt use if (myBoolean == true) or if (myBoolean == false).

You should use:

 

if (myBoolean) {

//Means boolean is true

}

 

or

 

if (!myBoolean) {

// Means Boolean is false

}

 

myBoolean stands for "true". So if you write myBoolean == true youre basically writing if (true == true) which returns true. See what i mean :D

It also makes the code a bit easier to read :D

What.. There is no reason to use if(myBool) over if(myBool == true). 

CPU: i7 4770k | GPU: Sapphire 290 Tri-X OC | RAM: Corsair Vengeance LP 2x8GB | MTB: GA-Z87X-UD5HCOOLER: Noctua NH-D14 | PSU: Corsair 760i | CASE: Corsair 550D | DISPLAY:  BenQ XL2420TE


Firestrike scores - Graphics: 10781 Physics: 9448 Combined: 4289


"Nvidia, Fuck you" - Linus Torvald

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3998537
Share on other sites

Link to post
Share on other sites

Btw you shouldt use if (myBoolean == true) or if (myBoolean == false).

You should use:

 

if (myBoolean) {

//Means boolean is true

}

 

or

 

if (!myBoolean) {

// Means Boolean is false

}

 

myBoolean stands for "true". So if you write myBoolean == true youre basically writing if (true == true) which returns true. See what i mean :D

It also makes the code a bit easier to read :D

I'll bare that in mind. hahah

Thank you.

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-3999808
Share on other sites

Link to post
Share on other sites

I don't know if US is one of them but in a lot of languages doing just if(bool) will be faster (of course not enough to care about.)

During compiling they will be optimized the the exact method.. Well at least in C#, C++, Java, ect.. I would say US would be the same.. 

http://stackoverflow.com/a/1070077

 

I'll bare that in mind. hahah

Thank you.

Please don't bare that in mind.. There is zero difference performance wise.. If you prefer "if(bool == true)" use it.. 

CPU: i7 4770k | GPU: Sapphire 290 Tri-X OC | RAM: Corsair Vengeance LP 2x8GB | MTB: GA-Z87X-UD5HCOOLER: Noctua NH-D14 | PSU: Corsair 760i | CASE: Corsair 550D | DISPLAY:  BenQ XL2420TE


Firestrike scores - Graphics: 10781 Physics: 9448 Combined: 4289


"Nvidia, Fuck you" - Linus Torvald

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-4000607
Share on other sites

Link to post
Share on other sites

During compiling they will be optimized the the exact method.. Well at least in C#, C++, Java, ect.. I would say US would be the same.. 

http://stackoverflow.com/a/1070077

 

Please don't bare that in mind.. There is zero difference performance wise.. If you prefer "if(bool == true)" use it.. 

 

Say "NO" to writing redundant and needless code!

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-4001577
Share on other sites

Link to post
Share on other sites

During compiling they will be optimized the the exact method.. Well at least in C#, C++, Java, ect.. I would say US would be the same.. 

http://stackoverflow.com/a/1070077

 

Please don't bare that in mind.. There is zero difference performance wise.. If you prefer "if(bool == true)" use it.. 

hahah thanks to vanilla JS I'm used to the original method I used, I'm sure I'll end out doing that anyway. haha

Link to comment
https://linustechtips.com/topic/291986-unityscript/#findComment-4007280
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×