Hi everyone, I’m a newbie in scripting here. I need advice on solving this problem here. I just want to rotate the GameObject (with smoothing) by a fixed 90 degrees on x-axis whenever i drag it. This is my script for drag and rotate :
var cubeThing : Transform;
var lastMousePosition : Vector3;
function Update(){
if(Input.GetMouseButton(0)){
if(Input.GetMouseButtonDown(0)){
//reset
lastMousePosition = Input.mousePosition;
}
else if(Input.mousePosition.x < lastMousePosition.x){
cubeThing.Rotate(
Vector3.up*(Input.mousePosition.x - lastMousePosition.x));
}
lastMousePosition = Input.mousePosition;
}
}
Thus is my problem now. I do not know how to make it perform a gradual rotation. My only clue after researching is that Mathf.SmoothDampAngle is the key to my answer but I do not know how to apply it after multiple failures. I’m pretty sure I’m just totally misunderstanding the concept of how to either use SmoothDampAngle, or how to then apply it to rotation over time. Any form of help will be greatly appreciated.
Many thanks.