- Home /
Question by
neogamesproduct · Aug 18, 2013 at 02:28 PM ·
smoothsmoothingmouse-look
try to get wanted position by mouse look smooth
i find this script :
private var xtargetRotation:float=10;
private var ytargetRotation:float=10;
var xSensitivity:float=10;
var ySensitivity:float=10;
var smoothing=2;
var min=-60;
var max=60;
function Update ()
{
var yAxisMove:float=Input.GetAxis("Mouse Y")*ySensitivity; // how much has the mouse moved?
ytargetRotation+=-yAxisMove; // what is the target angle of rotation
ytargetRotation=ytargetRotation % 360;
ytargetRotation=Mathf.Clamp(ytargetRotation,min,max);
var xAxisMove:float=Input.GetAxis("Mouse X")*xSensitivity; // how much has the mouse moved?
xtargetRotation+=xAxisMove; // what is the target angle of rotation
xtargetRotation=xtargetRotation % 360;
transform.localRotation=Quaternion.Lerp(transform.localRotation,Quaternion.Euler(ytargetRotation,0,0),Time.deltaTime*10/smoothing);
transform.parent.rotation=Quaternion.Lerp(transform.parent.rotation,Quaternion.Euler(0,xtargetRotation,0),Time.deltaTime*10/smoothing);
}
but whenever (not english lol) i start the game , the play start at rotation y 9.999999 , but i wanna start when i want to ....
any modifications or tip ????
Comment
Answer by 2d4Games · Aug 19, 2013 at 03:08 PM
Your player will start with that rotation because your variable ytargetRotation is equal to 10. Set xtargetRotation and ytargetRotation equal to the number you want them to start at.
Your answer
Follow this Question
Related Questions
Multipurpose CameraRig - Smooth Movement - how to achieve? 1 Answer
Problems with follow script (pet like) 2 Answers
Smooth mouse look 4 Answers