Quaternion.Slerp rotation speed increases over script life.

This is probably a basic slerp problem, but I’m using the arrow keys to switch between rotation points, and the speed in which it rotates gets faster and faster as the script goes on. If I leave the game running for about 20 seconds, my ship just snaps between rotations.

Any advice would be fantastic.

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

	private Transform ship;
	public Transform top;
	public Transform bottom;
	public Transform left;
	public Transform right;
	public Transform straight;
	Transform target;
	public float rotatespeed = 5f;
	public float translatespeed = 5f;
	
	void Start () {
		ship = transform;
		rigidbody.AddForce(-1000, 0, 0);
	}

	void Update () {


		//sets the rotations target based on what button is pressed
		if (Input.GetAxis("Vertical") > 0) {
			target = top;
		}
		else if (Input.GetAxis("Vertical") < -0) {
			target = bottom;
		}
		else if (Input.GetAxis("Horizontal") > 0) {
			target = right;
		}
		else if (Input.GetAxis("Horizontal") < -0) {
			target = left;
		}
		else{
			target = straight;
		}

		//ship 2D movement
		ship.Translate(Vector3.forward * translatespeed * Input.GetAxis("Horizontal") * Time.deltaTime);
		ship.Translate(Vector3.up * translatespeed * Input.GetAxis("Vertical") * Time.deltaTime);

		//ship rotation
		ship.rotation = Quaternion.Slerp(ship.rotation, target.rotation, Time.time * rotatespeed);
	
	}
}

Use Time.deltaTime instead of Time.time :slight_smile: (you might need to tweak your rotatespeed)