Okay, well the code I posted requires a continuous drag to complete but will stay within the parameters.
I think I have a better idea of what you’re looking for now. Try doing :
- declare a variable that will track your rotation.
- adjust it by +/- 90, depending on the click+drag direction.
- set the rotation to rotate towards the new rotation, based on your speed.
float rot = 0;
void Update() {
// your code here..
if( distancia > 0) {
rot += 90;
}
else if(distancia < 0) {
rot -= 90;
}
rot = Mathf.Clamp(rot, -90, 90);
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0,rot, 0), rotSpeed * Time.deltaTime);
So, try that with your code that is already there, adding the ‘rot’ outside of the method, and not using the rotate that you currently have.
Please look over this page for how to post code properly (nicely) on the forums: Using code tags properly