Cannot set boolean variable from another script

I have code that makes an object rotate, and its working ok if I call it from within the script.


public class ship : MonoBehaviour {
private bool toRotate=false;

    public void enemyRotate()
 	     toRotate = true;
     	 Debug.Log("er "+ toRotate);

 void Update () {
 if (toRotate)

			transform.RotateAround(player.transform.position, Vector3.forward, 100 * Time.deltaTime);


If I call enemyRotate from within scriptA, sure enough I get the rotation, and the debug log shows the variable has been set to true. But if I call it from another function like this:

Script B

  public class Projectile : MonoBehaviour {
      public ship ship_object;

      void Start(){
      ship_object=gameObject.AddComponent<kanaship> ();

      void callFunction(){


If I call it from callFunction, I get the Debug log saying the variable has been set to true, BUT the rotation animation is not working at all. I have tried different variants of this but cannot figure out what Im doing wrong. I have even used a public bool and tried to set that to true from another script but nothing. Help?

When using AddComponent you need to use the Class name for the component. So in your case:

ship_object = gameObject.AddComponent<ship> ();