I just have a basic question. I'm trying to learn how to use functions with unityscript and I learned that when you create a function using something like
function Example(text)
{
print(text);
}
and then call it up using
Example();
you can actually insert a string or a number into the parentheses on the latter piece of code in the parentheses and it will pass through and insert itself into the function you created previously. In this case, it does end up printing whatever I type into the parentheses.
Now, my question is if that works, then why don't functions where I pass in two numbers and ask to have them added work? The code I'm trying to use looks like:
Addition(4, 4);
function Addition(a, b)
{
print(a+b);
}
When I try to execute this, Unity tells me
Operator '+' cannot be used with a left hand side of type 'Object' and a right hand side of type 'Object'.
I was watching this video on Javascript functions and in the video at around 9 minutes, the guy types in exactly that, and gets the script to add it for him. I'm rather new to scripting and I do not have much of an idea of what I could be doing wrong. Thanks in advance for the help.