- Home /
How to enable the mouse cursor in some areas?
Hi everyone,
I'm trying to make to spin one object while I press the mouse left button and drag. so in that way I can spin my 3d object.
But now my problem is that the mouse cursor interfere with my other buttons.
Please see this little short video, maybe I can explain better.
Also I want to enable my script inside the blue square showed in my screenshots.
Also I want to enable my script inside the blue square showed in my screenshots.
Now I'm using this script to rotate my object.
var rotationSpeed = 10;
var rotationStart = 0.0;
var rotatehome = false;
function Awake ()
{
transform.Rotate(rotationStart,0,0);
}
function Update ()
{
if (Input.GetButton("Fire1")){
rotatehome = false;
var foo : float = Input.GetAxis("Mouse X");
Debug.Log(foo);
transform.eulerAngles.y = (transform.eulerAngles.y - Input.GetAxis("Mouse X") * rotationSpeed);
Return();
}
else if (rotatehome)
{
transform.rotation = Quaternion.RotateTowards(transform.rotation, new Quaternion(0,0,0,0.1), rotationSpeed);
}
}
function Return()
{
yield WaitForSeconds (0.5);
rotatehome = true;
}
Thanks for your help!
Answer by robertbu · Feb 05, 2013 at 05:32 AM
I'm not sure what you want to happen. You can either disable the buttons, or you can ignore mouse moves beyond a certain point. For the code below, I've added three lines of code that ignore mouse movement beyond a certain point on the X axis.
function Update ()
{
if (Input.GetButton("Fire1")){
var v3T : Vector3 = Input.mousePosition;
v3T = Camera.main.ScreenToViewportPoint(v3T);
if (v3T.x > 0.85) return;
rotatehome = false;
var foo : float = Input.GetAxis("Mouse X");
Debug.Log(foo);
transform.eulerAngles.y = (transform.eulerAngles.y - Input.GetAxis("Mouse X") * rotationSpeed);
Return();
}
else if (rotatehome)
{
transform.rotation = Quaternion.RotateTowards(transform.rotation, new Quaternion(0,0,0,0.1), rotationSpeed);
}
}
Thanks Robert, I want to disable my "360 rotate script" if the mouse cursor is outside of the blue rectangle.
I will try your script right now, Thanks $$anonymous$$an!
Your answer
Follow this Question
Related Questions
Disable Selection on Left button Mouse Click 3 Answers
Making an AirPlane follow mouse 1 Answer
Camera rotation around player while following. 6 Answers
Rotate Object with with mouse 1 Answer