Hello forum there was an unexpected problem for me , therefore, I would ask for your help to write a script that should be rotate the X and Z axis should be given a degree, for example, 15 degree .
And if possible move it with mouse .
Before that could you to use the script describing MouseLook in advance that it is not good because of X and Y axes only tried to rewrite but it don’t will work for me .
So i ask for your help.
Thank you in advance for your answers.
I hope my request is clear and understandable
Sorry for my bad english .
You can either rotate: Rotate(Transform.rightdegrees), then Rotate(Transform.updegrees)
- or if you know the exact angles you use eulerangles:
object.rotation.eulerAngles(new Vector3(xrotation,yrotation,zrotation));
Thank For Your Help
Now i have a problem with the mouse movement for my script . I write it so that the mouse move one game object that has the script will move to the mouse movement . I move the mouse its ok but i not move the mouse it will return to the original place .
So here is the script :
// Smoothly tilts a transform towards a target rotation.
var smooth = 2.0;
var tiltAngle = 30.0;
function Update () {
var tiltAroundZ = Input.GetAxis("Mouse X") * tiltAngle;
var tiltAroundX = Input.GetAxis("Mouse Z") * tiltAngle;
var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
// Dampen towards the target rotation
transform.rotation = Quaternion.Slerp(transform.rotation, target,
Time.deltaTime * smooth);;
}
With keyboard it works quite well .
So please help .