void OnTriggerEnter(Collider other) { TripControls brake = other.GetComponent <TripControls>(); // checks if object is tram if (brake) { if (endPlatform) { brake.SpeedChange(0); // stops tram if speed gets too low. should mean it reached the end platform } else { brake.SpeedChange(brake.movSpeed / 3); // decreases speed of tram based on current speed Destroy(this.gameObject); } Destroy(this.gameObject); } }
void OnTriggerEnter(Collider other) { TripControls boost = other.GetComponent <TripControls>(); // checks if object is tram if (boost) { boost.SpeedChange(boost.movSpeed * 3); // increases speed of tram based on current speed Destroy(this.gameObject); } }