- Home /
MissingMethodException error?
Here is my script. I keep on getting a error on the part about Application.Loadlevel (LoadingScreen2) and keeps on saying Missing Method Exception. Anyone know how to fix this?
var distance; var target : Transform;
var lookAtDistance = 15.0; var attackRange = 10.0; var moveSpeed = 5.0; var damping = 6.0; private var isItAttacking = false;
function Update ()
{
distance = Vector3.Distance(target.position, transform.position);
if(distance < lookAtDistance)
{
isItAttacking = false;
renderer.material.color = Color.white;
lookAt ();
}
if(distance > lookAtDistance)
{
renderer.material.color = Color.white;
}
if(distance < attackRange)
{
attack ();
}
if(isItAttacking)
{
renderer.material.color = Color.white
Application.LoadLevel ("LoadingScreen2");
}
}
function lookAt () { var rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping); }
function attack () { isItAttacking = true; renderer.material.color = Color.white;
transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);
}
Is "LoadingScreen2" a Scene in the project? I know its a stupid question and you probably already do. The name of the Scene must be that exactly; if there are spaces, they should be added to the string name of the scene.
If the scene is already in the project, you must add it to your build settings (File>Build Settings...) before it is recognized.
See here:http://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevel.html
Yes LoadingScreen 2 is a scene, and is added to the build settings. I tried using the numbers too ins$$anonymous$$d of the name, but that didn't work either.