You are trying to lerp to the same position you are already in. Try this and let me know if there is anything you need explained.
private float desiredRot;
public float rotSpeed = 250;
public float damping = 10;
private void OnEnable() {
desiredRot = transform.eulerAngles.z;
}
private void Update() {
if (Input.GetMouseButton(0)) {
if (Input.mousePosition.x > Screen.width / 2) desiredRot -= rotSpeed * Time.deltaTime;
else desiredRot += rotSpeed * Time.deltaTime;
}
var desiredRotQ = Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, desiredRot);
transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotQ, Time.deltaTime * damping);
}
It does work, but not exactly how I intended for it to. I am making the object rotate on it's Z axis. For example, I have my object going forward but rather than making it turn left/right I want it to turn the z axis (up/down). In a humanoid perspective (if we turn it 180 degrees) it's head will be where his feet were and his feet will be where his head was.
– MistyAcidSorry, never mind. I was hoping to get spoon fed but I realised it was a very bad thing. Then I tried to fix it myself, it is perfect now works fine. Thank you very much with your help! Helped me understand a bit more how to use the Lerping :)
– MistyAcidThat is not how you use Lerp. Time.deltaTime * damping (t value) is wrong in so many ways. First of all if you don't smoothly increment the t value you will simply not use Lerp. Second of all since Time.deltaTime is not fixed value it will go up and down, the movement will be vibrating.
– savantedroid