c# - The type or namespace name 'Score' could not be found -


i don't know why, see getting thrown error.. followed tutorial , haven't missed far have come this.

the type or namespace name 'score' not found (are missing using directive or assembly reference?)

playermotor.cs

using unityengine; using system.collections; using unityengine.ui;  public class playermotor : monobehaviour {     private charactercontroller controller;     private vector3 movevector;      private float speed = 10.0f;     private float verticalvelocity = 0.0f;     private float gravity = 12.0f;      private float animationduration = 3.0f;      private bool isdead = false;      void start () {         controller = getcomponent<charactercontroller>();     }      void update () {          if (isdead)             return;          if(time.time < animationduration)         {             controller.move(vector3.forward * speed * time.deltatime);             return;         }          movevector = vector3.zero;          if(controller.isgrounded)         {             verticalvelocity = -0.5f;         }         else         {             verticalvelocity -= gravity * time.deltatime;         }          // x - left , right         movevector.x = input.getaxisraw("horizontal") * speed;          // y - , dow         movevector.y = verticalvelocity;          // z - forward , backward         movevector.z = speed;           controller.move (movevector * time.deltatime);     }      public void setspeed(float modifier)     {         speed = 10.0f + modifier;     }      private void oncontrollercolliderhit (controllercolliderhit hit)         {         if (hit.point.z > transform.position.z + controller.radius)             death();         }      private void death()     {         isdead = true;         getcomponent<score>().ondeath();     } } 

score.cs

using unityengine; using system.collections; using unityengine.ui;  public class score : monobehaviour {     private float score = 0.0f;      private int difficultylevel = 1;     private int maxdifficultylevel = 10;     private int scoretonextlevel = 10;      private bool isdead = false;      public text scoretext;      void update () {          if (isdead)             return;          if (score >= scoretonextlevel)             levelup();          score += time.deltatime * difficultylevel;         scoretext.text = ((int)score).tostring ();     }      void levelup()     {         if (difficultylevel == maxdifficultylevel)             return;          scoretonextlevel *= 2;         difficultylevel++;          getcomponent<playermotor>().setspeed (difficultylevel);          debug.log (difficultylevel);     }      public void ondeath()     {         isdead = true;     } } 

i guessing both scripts have mentioned here not attached same game object. quick fix create variable score script in playermotor script , drag score script variable in editor set it. or

gameobject.find("player").getcomponent<score>().ondeath(); 

or maybe destroy gameobject of player on death, in case nothing work.


Comments