- Home /
Question by
paco morales · Mar 04, 2013 at 12:18 AM ·
mousemove
How to move one object with right mouse button?
Hello Everyone,
How I can assign my right button mouse to this script? I want to press my right mouse button and move my object.
This is the original script.
Please any advice is more than welcome!
var movedownY = 0.0;
var sensitivityY = 0.1;
function Update(){
movedownY += Input.GetAxis("Mouse Y") * sensitivityY;
if (Input.GetAxis("Mouse Y") != 0){
transform.Translate(Vector3.forward * movedownY);
}
movedownY = 0.0;
}
Comment
Best Answer
Answer by pazzesco · Mar 04, 2013 at 12:51 AM
If the above script works as intended, but you want to add another condition where the user must be clicking the right mouse button, then try this:
var movedownY = 0.0;
var sensitivityY = 0.1;
function Update() {
if (Input.GetAxis("Mouse Y") != 0 && Input.GetButton("Fire2")) {
movedownY += Input.GetAxis("Mouse Y") * sensitivityY;
transform.Translate(Vector3.forward * movedownY);
}
movedownY = 0.0;
}
NOTE: This is assuming you have the input "Fire2" mapped to your right mouse button!