how to build a crosshair to click on objects

Hello! I want to use a GUI-crosshair to click on objects in the game. I tried to use "Screen.lockCursor" to fix the cursor in the CENTER of the Screen. But the cursor is not in the center, on X it's centered but on the Y-axis it's not. Is the a bug? How can I do it? Greetings from Wuppertal

If you use Screen.lockCursor you basically disable the default mouse cursor. To display a custom cursor in gui space you will need to draw a texture and get the position (where to draw it) via Input.mousePosition.

Hi everyboby,

i got a gui crosshair in the middle of the screen and i have hide/locked the mouse cursor using

Screen.lockCursor = true; ( has i am in webplayer the cursor is automaticly hide )

My camera is an third person view with orbitScript.

i have a cyllinder in front of my caracter and i put this script in cyllinder

public bool testEloignement(){
	if( target.transform.position.x < transform.position.x - 2 && target.transform.position.x > transform.position.x + 2){
		if(target.transform.position.z < transform.position.z - 2 && target.transform.position.z > transform.position.z + 2){
			return true;	
		}else
			return false;
	}else	
		return false;
}
void OnMouseOver(){
	if(Input.GetMouseButtonDown(0) && testEloignement()){
		Debug.Log("clic");
	}
	Debug.Log("over");
}

But this works only if my cyllinder is between my caracter and the center of the screen.

I have try also to use raycast but maybe not in good way. Cause it do the same a OnMouseOver()

how can i do to clic on it in the frontside ?

Try:

`
function Update () {
Screen.lockCursor = true;
Screen.showCursor = False;

}

`

But remember to add something like:

`
    function OnGUI () {
    if(Input.GetButtonDown("Esc")){
    Screen.lockCursor = false;
Screen.showCursor = True;
}

}

`