void Update() { //do not continue if the tween reached its end if (move.tween == null || !move.tween.IsActive() || move.tween.IsComplete()) { return; } //check for user input if (Input.GetKeyDown(KeyCode.UpArrow)) { //resume tween the first time the game starts if (!move.tween.IsPlaying()) { move.Resume(); } //get desired speed after pressing the button //we add the desired value to the current speed for acceleration float speed = currentSpeed + addSpeed; //limit the speed value by the maximum value if (speed >= topSpeed) { speed = topSpeed; } //change the speed of the tween by the calculated value move.ChangeSpeed(speed); //restart slow down StopAllCoroutines(); StartCoroutine("SlowDown"); } //display values and increase timer speedDisplay.text = "YOUR SPEED: " + Mathf.Round(move.speed * 100f) / 100f; timeCounter += Time.deltaTime; timeDisplay.text = "YOUR TIME: " + Mathf.Round(timeCounter * 100f) / 100f; }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Selectin") { anim.SetBool("isHit", true); speedAdjust -= 0.5f; splineMoveScript.ChangeSpeed(speedAdjust); colSound.PlayOneShot(thump, 1f); Debug.Log("hit!" + speedAdjust); vibrate = true; } }
void Update() { if (_currentSplineMove == null) { return; } if (_accelerating) { _currentSpeed += (VehicleAcceleration * Time.deltaTime); if (_currentSpeed > VehicleSpeed) { _currentSpeed = VehicleSpeed; _accelerating = false; } _currentSplineMove.ChangeSpeed(_currentSpeed); } }
void OnTriggerEnter(Collider other) { splineMoveScript.ChangeSpeed(speedChange); Debug.Log("Current speed is: " + speedChange); }
public void SplineChangeSpeed() { Debug.Log("SplineChangeSpeed"); spline.ChangeSpeed(2); }
float GetPathPassTime(float passTime, splineMove sm, FishingPathData pd) { if (pd.m_ChangePoints.Count == 0) { return(passTime); } float value; float speed = sm.speed; float countTime = passTime; List <byte> changeList = new List <byte>(pd.m_ChangePoints.Keys); if (passTime > 0f) { sm.tween.ForceInit(); TweenerCore <Vector3, Path, PathOptions> tweenPath = sm.tween as TweenerCore <Vector3, Path, PathOptions>; float time = 0f; countTime = 0f; float curSpeed = speed; for (byte i = 0; i < sm.pathContainer.GetWaypointCount(); i++) { value = tweenPath.changeValue.wpLengths[i] / curSpeed; time += value; countTime += value; if (passTime <= time) { countTime -= (time - passTime); break; } if (pd.m_ChangePoints.ContainsKey(i)) { changeList.Remove(i); if (i >= sm.events.Count) { DebugLog.LogWarning("Error: fish point count(" + sm.events.Count + ") out path(" + pd.m_szPath + ") change config!!"); break; } value = pd.m_ChangePoints[i]; if (value > 0f) { sm.events[i].AddListener(() => sm.ChangeSpeed(value * speed)); curSpeed = speed * value; } else { time -= value; if (passTime <= time) { sm.events[i].AddListener(() => sm.Pause(time - passTime)); break; } } } } } foreach (byte i in changeList) { if (i >= sm.events.Count) { DebugLog.LogWarning("Error: fish point count(" + sm.events.Count + ") out path(" + pd.m_szPath + ") change config!!"); break; } value = pd.m_ChangePoints[i]; if (value > 0f) { sm.events[i].AddListener(() => sm.ChangeSpeed(value * speed)); } else { sm.events[i].AddListener(() => sm.Pause(-value)); } } return(countTime); }