Skip to content

Instantly share code, notes, and snippets.

@Sposito
Created June 9, 2016 02:45
Show Gist options
  • Save Sposito/03740ce86f7c367bada1b1535444fb9a to your computer and use it in GitHub Desktop.
Save Sposito/03740ce86f7c367bada1b1535444fb9a to your computer and use it in GitHub Desktop.
// >>>>>>>>>>>>Player Controller.cs<<<<<<<<<<
//...
public void BoostSpeed(float duration, float factor){
StartCoroutine (BoostCoroutine(duration,factor));
}
private IEnumerator BoostCoroutine(float duration, float factor){
boostFactor *= factor;
rend.materials [2].color = boostColor;
yield return new WaitForSeconds (duration);
boostFactor /= factor;
rend.materials [2].color = baseColor;
}
}
//<<<<<<<<<Boost.cs >>>>>>>
public float duration = 5f;
public float factor = 1.6f;
PlayerController pController;
void Start () {
pController = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerController> ();
}
void OnTriggerEnter(Collider col){
pController.BoostSpeed (duration, factor);
Destroy (gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment