- Home /
Solve Script class error
There is a problem that is new to me. I imported alot from Blender (models and animations) and everything was perfect. Now I imported my new enemy with 5 animations (I'm useing only 3 but its not the problem) and when i try to put the scrips on the enemy I get an error that say this:"Can't add script behaviour R.H.Control. The script file name does not match the name of the class defined in the script!" ("R.H.Control" is the name of the scrips I created for the enemy). Where/What is the problem??? What does it meen??
If the problem is in my script so please check it:
var distance; var target : Transform; var lookAtDistance = 160.0; var attackRange = 140.0; var deadRange = 100.0; var moveSpeed = 10.0; var damping = 4.0; var shootTest = 0; //the var "shootTest" is for the effect of animation. after the enemy shoots, he put his gun away. //it to make shure that he will do it only after he shoot. static var ableFire = false;
function Update ()
{
distance = Vector3.Distance(target.position, transform.position); if(distance < lookAtDistance) {
renderer.material.color = Color.yellow; animation.Play("GoingToShoot"); lookAt ();
}
if(distance > lookAtDistance)
{
renderer.material.color = Color.green;
}
if((distance < attackRange)&&(distance > deadRange))
{
if (shootTest > 0)
{
animation.Play("StopShoot");
shootTest = 0;
}
attack ();
}
if(distance < deadRange)
{
stop ();
shootTest ++;
ableFire = true;
}
}
function lookAt () { var rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping); }
function attack () {
ableFire = false; renderer.material.color = Color.red;
transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime); animation.Play("R.H.Walk"); }
function stop () { renderer.material.color = Color.black; }
Sorry for poor english...
Answer by Uzquiano · May 05, 2011 at 07:45 PM
Take away the dots, just put RHControl
btw, if you are coding in JavaScript you should create a javascript script, meaning that the script should end wit ".js"
Thanks mate! It works. (such a stupid thing to solve it... I never thought on that...)
You are welcome. I'm pretty sure that when I will start using Blender this kind of things will happen to me too ;)
Now there is another problem: The enemy "dance", it do the same animation in loops when it should aim on me and it looks like "danceing robot". when it needs to do another animation it just stop do the animation, don't do the animation it needs to do and after that it start "dance" again... After I checked it not should do it in loops, it says its do it one time...
Your answer

Follow this Question
Related Questions
Why isn't this mesh not appearing properly? 0 Answers
Error Rotation Object when add animation 0 Answers
Blender UV map texture problem? 1 Answer
Fatal error with import from Blender 2 Answers
why isnt my object showing up? 1 Answer