// Detects Trigger Collision void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "AirMachine" && onStar == false) { //print ("Air Ride found!"); anim.SetBool("Hopping on", true); //Certain Rides have special features if (col.gameObject.name == "JetStar") { jsp = col.gameObject.GetComponent <JetStarParticles> (); } if (col.gameObject.name == "SwerveStar") { sse = col.gameObject.GetComponent <SwerveStarEffects> (); } endPos = col.gameObject.GetComponent <AirRide> ().getSitHeight(); jumpingOnStar = true; col.gameObject.tag = "KirbyMachine"; StartCoroutine(JumpOnStar(this.transform, endPos, moveSpeed * Time.deltaTime * 20)); StartCoroutine(RiderOn(col.gameObject)); cam.transform.parent = transform; cam.GetComponent <CameraControl> ().enabled = false; // Kirby no more hit detection sphereCol.enabled = false; rb.isKinematic = true; } }
// Jumping off of the Air Ride private IEnumerator JumpOffStar() { // Kirby no longer dependent on vehicle, and vice versa. airRide.transform.parent = null; airRide.gameObject.tag = "AirMachine"; ar.charge = 0; ar.resetRotation(); ar = null; onStar = false; jumpCharge = 0; cam.transform.parent = null; cam.GetComponent <CameraControl> ().enabled = true; // Make all vehicle stats go back // Resetting particle effects for vehicles. if (jsp != null) { jsp.StopParticles(); jsp = null; } if (sse != null) { sse.StopParticles(); sse = null; } // Undo UI for vehicles ui.enabled = false; // Jumps Kirby Up, for a "Pop off" effect. rb.velocity += Vector3.up * moveSpeed * Time.deltaTime; // He isn't charging anymore, so appropriate the animations. anim.SetBool("Charging", false); anim.SetBool("JumpingOff", true); anim.SetBool("Jumping", false); anim.SetBool("Jumping2", false); anim.SetBool("Riding", false); // Don't re-enable his sphere collider for a few seconds so he won't instantly hop back on a ride. yield return(new WaitForSeconds(1f)); sphereCol.enabled = true; anim.SetBool("JumpingOff", false); }