using a plane (game object) as a crosshair problem

hi, i’m trying to use a plane game object as a crosshair, but don’t know how to move it using code, so far this is my code right now

       void Update () {
		
		float posX=Input.mousePosition.x;
		Vector3 NewPos;
		NewPos=transform.position;
		NewPos.x=posX;
	        transform.position=NewPos;
	}

that script was added to the plane object in the world editor, but didn’t move the plane in runtime, i used this too

    Plane PlaneCrossHair;
    PlaneCrossHair=GameObject.Find("CrossHairPlane");

but the PlaneCrossHair don’t have a transform method or any function to change it’s position.

somebody can help me to figure out this ? or point me to a good cross hair tutorial, i have search many times and i didn’t found anything good for me.

thanks in advance for all your help.

You trying to get a standard crosshair that is always in the middle of the screen? Or a crosshair which is inside the world? Or a crosshair which can move across the screen independent of the camera?

Assuming that you are using crosshair for obvious reasons (aiming) you should probably look at the Cursor class to set the cursor to your own image as well as Screen class to show, hide and lock the cursor.

http://docs.unity3d.com/Documentation/ScriptReference/Screen.html

http://docs.unity3d.com/Documentation/ScriptReference/Cursor.html

i’m trying to set a crosshair that can be moved along the camera in the x axis, but it will not follow the camera on the y axis.

i will check your links cdevl.

thanks for the responses.

thank you cdevl, i figure it out using your links, thank you very much.