trying to use getComponent to get a variable to feed into the mover script

i have finished the spaceShooter tutorial and am trying to flesh it out for fun and increased knowledge. What i am tring to do is increase the speed of the asteroids every 50 points. the mover scripts controls the speed of the asteroids. when they are instanced.

public class mover : MonoBehaviour
{

private int currentSpeed;


void Start () 
{
	currentSpeed = GameController.GetComponent(speedSetter);
	rigidbody.velocity = transform.forward * currentSpeed;

}

// Update is called once per frame
void Update () 
{
	
}

}

current speed is controlled in the GameController.

private int score;

public void speedSetter()
{

	if (( score % 50 ) == 0)
	{
		speed = (speed --);
	}

}

the error i get is: An object reference is required to access non-static member `UnityEngine.Component.GetComponent(System.Type)’

but i thought that getComponent would handle this. what should i try instead?

thanks

First you should declare the GameController variable in the beginning of the class mover.

GameController gamecontroller;

Then you should make the reference to the GameController component in the start/awake function just like you’re trying to do at the moment.

void Start() {
     gamecontroller = GetComponent<GameController>();
}

Now you should be able to call the function speedSetter through this reference.

void Start() {
         gamecontroller = GetComponent<GameController>();
         currentspeed = gamecontroller.speedSetter();
    }

Let me know if this helped.

thanks that did help. my code compiles now which is a big step forward. however the asteroids no longer move. for some reason the speedSetter seems to be 0.

here is the mover() code

public class mover : MonoBehaviour
{
private int currentSpeed;
GameController gamecontroller;

// Use this for initialization
void Start() 
{
		
	gamecontroller = GetComponent<GameController>();
	currentSpeed = gamecontroller.speedSetter();
	rigidbody.velocity = transform.forward * currentSpeed;

}	

}

and here is the speedSetter() code on the GameController

private int score;

private int speed;

void Start ()
{
score = 0;
UpdateScore ();
speed = -10;
}

public void AddScore (int newScoreValue)
{
score += newScoreValue;
UpdateScore ();
}

void UpdateScore ()
{
	scoreText.text = "Score: " + score;
}

public int speedSetter()
{

	if (( score % 50 ) == 0)
	{
		 
		speed = (speed += -5);

	}
	return speed;

}

any thoughts on how to get a number other than zero would be great. also if you could tell me why i am getting zero i would be really grateful.
thanks