- Home /
BCE0017 trouble with TWBS Tutorial
Hi all, I'm a complete noob, be gentle.
I've been using the Walker Brothers unity tutorial. So far I'm getting the basics of JavaScript/UnityScript down. I've managed to work out most issues I have ran into, but in this instance, this simple script is throwing up an error when I'm trying to use an overload method (correct me if I am wrong in my terminology).
The script is as follows:
function Update ()
{
Donkey=Person("Donkey");
Horse=Person("Horse");
Donkey.TeamUp("Horse");
}
class Person
{
var name;
function Person(n:String) //constructor
{
name = n;
}
function TeamUp(p:Person)
{
print(name+" teamed up with " + p.name+"!");
}
}
Error reads as:
Assets/scripting_basics_1.js(332,21): BCE0017: The best overload for the method 'Person.TeamUp(Person)' is not compatible with the argument list '(String)'.
As far as I can tell, everything is correct as far as the Tutorial suggests, obviously there is something not formatted correctly. If someone could kindly share the correct method of pairing up Donkey and Horse via print and offer an explanation as to why I got this error. Any help is much appreciated. Thank you in advance.
Answer by Dave-Carlile · Feb 11, 2013 at 05:19 PM
The TeamUp
function requires a parameter of type Person
. You're passing in a string. You want to pass in the actual object instance Horse
, like so:
Donkey.TeamUp(Horse);
Note there are no quotes there - you want to pass in the variable Horse
, not the string "Horse"
.
Answer by CanneyDraws · Feb 11, 2013 at 05:58 PM
Ah, I had been staring at my code vs the example code too long and overlooked my inclusion of the quotes. Thank you Dave, I now have a better understanding and wouldn't have realised without your intervention.
this man.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092521im_/https://answers.unity.com/themes/thub/images/avi.jpg)