title: How to get variables from a derived class into an inherited class
body: <p>I'm currently developing PacMan as a school project. I have a base class called ghosts that finds the shortest path from the ghost to the target location. I also have classes such as red ghost which inherit it, these will give the base class a target and the current location of the ghost as well. When I use the red ghost it works... the variables are changed in the base class and then can be used, but for any of the other ghosts it won't work, and I can't seem to see why. Any help is appreciated :) </p>
  
  <pre><code>    pinkghost = new PinkGhost();
      redghost = new RedGhost();
  
      pinkghost.SetVariables();
      pinkghost.ChaseMode();
      redghost.SetVariables();
      redghost.ChaseMode();
  
  public abstract class Ghosts
  {
      public int ScatterX;
      public int ScatterY;
      public int TargetX;
      public int TargetY;
      public int GhostPosX;
      public int GhostPosY;
      public int StartNodeX;
      public int StartNodeY;
      public float speed = 1.0f;
  
      abstract public void SetVariables();
      abstract public void ChaseMode();
  
      public Ghosts()
      {
          //Allows ghost to access pacman coords
          PacMan = GameObject.Find("pacman");
      }
  
  
  public class RedGhost : Ghosts
  {
      public override void SetVariables()
      {
          GhostMov = gameobject.Find("blinky");
          ScatterX = 24;
          ScatterY = 3;
          GhostPosX = 13 + Convert.ToInt32(GhostMov.transform.position.x);
          GhostPosY = 15 - Convert.ToInt32(GhostMov.transform.position.y);
      }
  }
  
  // This one works…
  class PinkGhost : Ghosts
  {
      public override void SetVariables()
      {
          GhostMov = gameobject.Find("pinky");
          ScatterX = 4;
          ScatterY = 3;
          GhostPosX = 13 + Convert.ToInt32(GhostMov.transform.position.x);
          GhostPosY = 15 - Convert.ToInt32(GhostMov.transform.position.y);
      }
  }
  </code></pre>
  
  <p>So as I said the red Ghost setvariables and chasemode work... but the pink ghost does not for some reason?</p>