ScreenPointtoRay Creating problems for mouse follow script

I am confused as to why my game cursor follow script does not seem to perform differently based on the character’s position. I want the player to press “E” if the player hovers the mouse over the character’s hand and clicks and drags the arm will move up and down following the mouse position.

The script was working until I moved my character along the X axis and found that the location the mouse had to click and drag stayed at the arm’s original position even as the character, his arm, and camera moved away. Would anyone have any idea why? I’ve pasted in the script for finding the Mouse’s position and the script for having my game object copy the mouse’s position.

I uploaded some videos of the script working on YouTube as well - YouTube - YouTube

Thanks for your time!

public static class GameCursor
    public static LayerMask mask;
    public static Vector2 WorldPosition
            float distance;
            int mask = 1<<9; //setting layer mask to layer 9
            mask = ~mask; //setting the layer mask to ignore layer(~)
                //adding in the layermask to raycast will ignore 9th layer
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(ray.origin, ray.direction * 10000f,;
            if (_gamePlane.Raycast(ray, out distance))
                return ray.GetPoint(distance);
    private static Plane _gamePlane = new Plane(Vector3.forward,0);

point at cursor script----------------------------------------------------------------------------------------------

    public GameObject ArmR;
    public static Vector2 OffsetPoint;
    public Vector2 OffsetVec2;
    void Start ()
    private void Update()
        if (Input.GetKey (KeyCode.E)) {
            Follow ();
        if (Input.GetKeyUp (KeyCode.E)) {
        //print (transform.eulerAngles.z);
        //Offset.transform.position = OffsetVec2;
        OffsetPoint = GameCursor.WorldPosition + OffsetVec2;
        Vector3 clampedRotation = transform.eulerAngles;
        // Clamp the z value
        if (clampedRotation.z > 90.0f) clampedRotation.z = 180.0f - clampedRotation.z;{
            clampedRotation.z = Mathf.Clamp (clampedRotation.z, 0, 90);
            clampedRotation.z = Mathf.Clamp (clampedRotation.z, -90, 180);
        // assign the clamped rotation
        ArmR.transform.rotation = Quaternion.Euler(clampedRotation);
        //if(ArmR.transform.eulerAngles.z >= 350 || transform.eulerAngles.z <= 270){
            //Debug.Log ("no");
        if(ArmR.transform.eulerAngles.z == 0){
            //Debug.Log ("AT0");
        if(ArmR.transform.eulerAngles.z == 90){
            //Debug.Log ("AT90");
void Follow(){
        ArmR.transform.up = -GameCursor.WorldPosition + OffsetVec2;
    private void OnDrawGizmos()
        Gizmos.DrawIcon(GameCursor.WorldPosition, "wallll", true);

You are receiving the point on the mouse cursor is on the screen with GameCursor.WorldPosition, then you are adding some offset to it OffsetPoint = GameCursor.WorldPosition + OffsetVec2 and then you never use OffsetPoint again.
I think that’s the problem.