protected void Start() { cart = gameObject.GetComponentInParent <TrackCart>(); rb = cart.GetComponent <Rigidbody>(); if (!cart) { Debug.LogWarning("No parent TrackCart, cannot spin wheels", this); return; } }
private IEnumerator StopTheCart() { var rb = currentCart.GetComponent <Rigidbody>(); //brakes were already set in WaitForCart, so just wait while (VerifyCart() && rb.velocity.magnitude - speedTolerance > stoppingForce.targetSpeed && holdCart) { yield return(fixedWait); } if (!holdCart) { yield break; } StartCoroutine(currentCart ? WaitForLoading() : WaitForCart()); }
public void Update() { //Track their cart with the camera var behind = -cart.transform.forward; behind.y = 0; behind.Normalize(); Camera.main.transform.position = behind * 5 + cart.transform.position + Vector3.up * 2; Camera.main.transform.LookAt(cart.transform); foreach (var course in courses) { // ReSharper disable once CompareOfFloatsByEqualityOperator if (course.lastSliderValue != course.speedSlider.value) { //This was moved last, switch to this one. var val = course.speedSlider.value; WipeSliders(); course.lastSliderValue = course.speedSlider.value = val; var pieces = GetPieces(course.track); //jump to the right course if we aren't there if (!pieces.Contains(cart.CurrentTrack)) { cart.CurrentTrack = course.track; course.track.TrackAbsoluteStart.ApplyTo(cart.transform); cart.GetComponent <Rigidbody>().velocity = Vector3.zero; } foreach (var piece in pieces) { piece.acceleration.targetSpeed = val; piece.brakes.targetSpeed = val; } //we are done here return; } } }