I have a question regarding the Mathf.SmoothDampAngle
function. I have a plane, which I am trying to tilt randomly in different directions. I want it to be constrained to a maximum x rotation and a maximum z rotation. I do not want it to rotate on the y axis (spin) yet. This is the code I am using, and it does what I want, but it does not do it smooth enough, neither does it seem to use the whole range of the constraints that I put. (Which are 45 degrees in each direction).
Does Anyone have any ideas as to what I can change to make the platform tilt back and forth on the x and z axis smoothly with a controllable speed and controllable range?
My code is as follows:
rotX = Random.Range (MIN_ROTATION, MAX_ROTATION);
rotY = Random.Range (MIN_ROTATION, MAX_ROTATION);
rotZ = Random.Range (MIN_ROTATION, MAX_ROTATION);
float xAngle = Mathf.SmoothDampAngle (transform.eulerAngles.x, rotX, ref velocity, smooth, Mathf.Infinity, Time.deltaTime);
float yAngle = Mathf.SmoothDampAngle(transform.eulerAngles.y, rotY, ref velocity, smooth);
float zAngle = Mathf.SmoothDampAngle (transform.eulerAngles.z, rotZ, ref velocity, smooth, Mathf.Infinity, Time.deltaTime);
Vector3 newRot = new Vector3(xAngle, 0.0f, zAngle);
rigidbody.transform.rotation = Quaternion.Euler(newRot);