Im currently creating a 2d side scrolling game. When the character (which is a bike) hits the boost he speeds up, but I cant seem to get him to slow down again. I should point out that the character is actually immobile and the environment around him is moving (I did this because I wanted to create a parallax effect with the background). When he hits the boost, the environment speeds up. The codes something like this:
void OnTriggerEnter(Collider theCollision){
if(theCollision.gameObject.name == "Token Boost") {
Debug.Log ("Hit the item boost!");
Destroy (theCollision.gameObject);
foreach(GameObject go in GameObject.FindGameObjectsWithTag("environment")){
go.GetComponent<parallax>().Speed *= 0.5f;
}
}
If you could help me out id greatly appreciate it