How would I script the following?
"If any of the following conditions are met…
mposX < 0
mposX > Screen.width
mposY < 0
mposY > Screen.height
then execute some code…
How would I script the following?
"If any of the following conditions are met…
mposX < 0
mposX > Screen.width
mposY < 0
mposY > Screen.height
then execute some code…
if(mposX < 0 || mposX > Screen.width || mposY < 0 || mposY > Screen.height) {
// execute some code
}
Thanks for that but I still can’t get my script to work. I’m basically trying to disable MouseLook when the cursor moves outside of the player window. Here’s my full code:
function Update () {
if(Input.mousePosition.x < 0 || Input.mousePosition.x > Screen.width || Input.mousePosition.y < 0 || Input.mousePosition.y > Screen.height) {
** GetComponent (MouseLook).enabled = false;**
** }**
Could anyone offer advice on what I’m doing wrong here?
Looks OK from here but try breaking it into bits to debug what is going wrong.
if(Input.mousePosition.x < 0 ) {
Debug.Log(“Lower than 0”);
GetComponent (MouseLook).enabled = false;
}
etc…
(also, Screen.width and hieght were a little buggy when running in the Editor, that may be the issue)
pakfront, you are correct - it does work whenk playing the build. I should have tried that myself…doh!
Many thanks