- Home /
Reset speed after a specified time
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
use Invoke() and InvokeRepeating() for basic timers in Unity when you are a beginner. read documentation on same. unityGE$$anonymous$$S.com for many long articles on this
Your answer
Follow this Question
Related Questions
increasing speed and time of spawn game object 0 Answers
Limited Energy Regeneration 3 Answers
Boost Script Time problems 1 Answer
Reset speed after a specified time 1 Answer