Hi…
I want to learn much about unityscripting, i´d like to see some medium skill tutorials… how to write script with unityscript… and things like that…
for now what I can understand is :
if statements
while bucles
Start, Update, FixedUpdate, OnTrigger, OnMouse functions
static and commons vars
what i want to learn is about “for”, and “arguments” of a function, and other more skilled things…
i really apreciate your help thanks…
Well, while you’re waiting for the tutorial…
A “for” loop is the same as a “while” loop except that you can also declare a piece of code that will happen at the start of the loop and something that will happen each time round the loop after the body has executed (this is typically used to advance the loop to the next step). It looks like this:-
for (start code; loop condition; advancement) {
loop body
}
It is most often used as a counted loop:-
for (i = 0; i < 10; i++) {
// Something that may or may not use the value of i.
}
This means “start off with i set to zero; continue while i < 10; at the end of each iteration, add 1 to i”.
There is actually another type of “for” loop that gives you a shorthand for looping over items in an array or other collection:-
for (variable in collection) {
// Something that probably uses the variable value.
}
For example:-
// Loop through all child objects.
for (child: Transform in transform) {
}
Arguments are simply the values passed into a function call:-
var x = Mathf.Sqrt(2); // 2 is the argument to this function call.
oh yes!. precisely the “i” as an argument var was unknown for me too and you made it clear… thank you for explaining… !