- Home /
Question by
ibrahimarslan · Feb 10, 2012 at 09:37 PM ·
charactercontrollermouselookconflict
MouseLook And CharacterController Script Conflict it !
Hi ! Mouse look problem is my character controller and Mouselook script conflict it.
This is my characterController rotation script
private var horizx:float=0.0;
var karakterDonusHizi:int=20;
function Update () {
horizx+=Input.GetAxis("Mouse X")*karakterDonusHizi*Time.deltaTime;
transform.rotation.eulerAngles=Vector3(0,horizx,0);
}
and my MouseLook Script conflict to the character controller. Activate to aktifY And rotation y axis and off aktifX.I don't activated mousex , Conflict to controller..
var aktifX=true;
var aktifY=true;
var mouseHiz:int=10;
var smooth:float=2.0;
var mouseXmin:int=-120;
var mouseXmax:int=120;
var mouseYmin:int=-60;
var mouseYmax:int=60;
private var horizx:float=0.0;
private var horizy:float=0.0;
var aktifX=true;
var aktifY=true;
var mouseHiz:int=10;
var smooth:float=2.0;
var mouseXmin:int=-120;
var mouseXmax:int=120;
var mouseYmin:int=-60;
var mouseYmax:int=60;
private var horizx:float=0.0;
private var horizy:float=0.0;
function Update () {
if (aktifX==true && aktifY==true) {
horizx+=Input.GetAxis("Mouse X")*mouseHiz*smooth*Time.deltaTime;
horizx=Mathf.Clamp(horizx,mouseXmin,mouseXmax);
horizy+=Input.GetAxis("Mouse Y")*mouseHiz*smooth*Time.deltaTime;
horizy=Mathf.Clamp(horizy,mouseYmin,mouseYmax);
transform.rotation.eulerAngles=Vector3(-horizy,horizx,0);
}
else if (aktifX==true){
horizx+=Input.GetAxis("Mouse X")*mouseHiz*Time.deltaTime;
horizx=Mathf.Clamp(horizx,mouseXmin,mouseXmax);
transform.rotation.eulerAngles=Vector3(0,horizx,0);
}
else if (aktifY==true){
horizy+=Input.GetAxis("Mouse Y")*mouseHiz*Time.deltaTime;
horizy=Mathf.Clamp(horizy,mouseYmin,mouseYmax);
transform.rotation.eulerAngles=Vector3(-horizy,0,0);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613063946im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
First Person Controller MouseLook on Android 2 Answers
rotate player towards the mous 1 Answer
Screen.lockCursor leaves mouse where it was 2 Answers
Mouse movement swings character around in circles 1 Answer
Vertical axis not working properly 0 Answers