Simple Question
Hi it's me again, with another question :)
i was wondering what these brackets after function Update or over functions are:
function Update(//what can you do with these?!)
Answer by Karsnen_2 · Mar 27, 2013 at 01:44 PM
Ar asking about the angle"()" brackets followed after Update ?
That is just a protocol to define any method. It has been in existent since C and we have been following it in the subsequent programming languages. And Update is also a method which Unity call in for every Time.deltaTime.
If there is anything specific you want to know, let me know.
To throw a generic document about methods, here it is
They are necessary... I would recommend to get the basics of C# well done before you could dip yourself into Unity. If not C# any other program$$anonymous$$g language.
I think i'll be okay with my javascript skills ( xD )
But if you have an other function... like
function OnTriggerEnter(other:Collider) {}
you write something in these brackets... can you do something like that with the function Update brackets?
Answer by murkantilism · Apr 03, 2013 at 07:45 PM
Those are parenthesis, not brackets.
{ } <-- These are brackets.
Parenthesis are used define methods, and invoke method calls. They are used to differentiate methods from other types of code. Example:
int foo = 5; // A variable named foo
void foo(){ // A method named foo
return "hello";
}
print foo // This prints 5
print foo() // This prints hello
As you can see in the example, brackets are used to define the body of the method. You can also insert arguements into the parenthesis of a methed, like this:
// This takes a number as an argument and adds 1 to it
void foo(aNumber){
aNumber += 1;
}
I highly suggest you familiarize yourself with basic programming techniques before doing anything in Unity. Otherwise you'll keep coming back here and flooding UnityAnswers with incredibly basic questions like this. Sorry but I have to downvote the question, it doesn't belong here. Google "basic programming" and do some tutorials.
Your answer
Follow this Question
Related Questions
How do you stop a function with another function? 2 Answers
OnMouseEnter is blinking 1 Answer
How to call functions from another script c# (Unity5) 1 Answer
GameJolt API simple Score 0 Answers
If statement noop :) 1 Answer