- Home /
Mouse and Game controller at the same time
Hello Unity community,
I'm trying to get a character to be controlled by both a mouse and a game controller. I can get them to work seperately by referencing the respective axes that have been set in the input manager.
However I have no idea how to get the script to look at the input of both devices at the same time.
I'm using the following mouselook script that I found somewhere on this site:
 private var xtargetRotation:float= 10;
 private var ytargetRotation:float= 10;
 var xSensitivity:float= 10;
 var ySensitivity:float= 10;
 var smoothing : float = 0.5;
 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);
 
 }
It's basically a mouselook script that adds some smoothing. I can replace the "Mouse Y" with the name of the Y axis of the controller; which works great. But is there a way to tell the engine to look at both the Mouse X & Y aswell as the respective Controller Axes simultaniously from within the same script?
I would just add the values of the mouse and the controller, ins$$anonymous$$d of replacing them with one another.
Your answer
 
 
             Follow this Question
Related Questions
How to calculate mouse and game pad input together? 1 Answer
How do I standardize my game's input to different types of controllers? 1 Answer
Use Gamepad right analog stick instead of mouse to control crosshair movement 3 Answers
Handling Controller disconnection? (reassignment, clunkyness, etc.) 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                