// Update is called once per frame void LateUpdate() { Vector3 lookAtGoal = new Vector3(goal.position.x, this.transform.position.y, goal.position.z); Vector3 direction = lookAtGoal - this.transform.position; this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), Time.deltaTime * rotSpeed); // speed = Mathf.Clamp(speed + (acceleration * Time.deltaTime), minSpeed, maxSpeed); if (Vector3.Angle(goal.forward, this.transform.forward) > brakeAngle) { speed = Mathf.Clamp(speed - (deceleration * Time.deltaTime), minSpeed, maxSpeed); } else { speed = Mathf.Clamp(speed + (acceleration * Time.deltaTime), minSpeed, maxSpeed); } this.transform.Translate(0, 0, speed * Time.deltaTime); AnalogueSpeedConverter.ShowSpeed(speed, 0, 100); readout.text = "" + speed; }
// Update is called once per frame void Update() { //Insert your cURL here: string url = "https://api.particle.io/v1/devices/230039000a47353138383138/Alcohol?access_token=fc30489129ccbad879a2e3921485501418ada51c"; www = new WWW(url); StartCoroutine(WaitForRequest(www)); AnalogueSpeedConverter.ShowSpeed(ForceInput, 0, 100); //Send Force reading to analog dial. }
// Update is called once per frame void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; rb.AddForce(this.transform.forward * translation * 40); rb.AddTorque(this.transform.up * rotation * 15); AnalogueSpeedConverter.showSpeed(rb.velocity.magnitude, 10, 140); }
// Update is called once per frame void LateUpdate() { Vector3 lookAtTarget = new Vector3(goal.position.x, this.transform.position.y, goal.position.z); //get direction Vector3 direction = lookAtTarget - transform.position; transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), Time.deltaTime * rotSpeed); if (Vector3.Angle(goal.forward, transform.forward) > breakeAngle && speed > 10f) { speed = Mathf.Clamp(speed - (deaccleration * Time.deltaTime), minSpeed, maxSpeed); Debug.Log("deaccleration - Angle : " + Vector3.Angle(goal.forward, transform.forward)); } else { speed = Mathf.Clamp(speed + (accleration * Time.deltaTime), minSpeed, maxSpeed); } transform.Translate(0, 0, speed); AnalogueSpeedConverter.ShowSpeed(speed, minSpeed, maxSpeed); speedText.text = Mathf.RoundToInt(speed).ToString(); }
// Use this for initialization void Start() { thisSpeedo = this; }
// Use this for initialization void Start() { thisSpeedo = this; //Assign this game object to this Speedometer }