Confusing question

Hello everyone! I’m very new to unity and I need some help.
The problem I’m having right now is not really significant but I can’t solve it and its driving me slightly insane.

I have a script that looks like this:

using UnityEngine;
using System.Collections;


public class GetPlayerPos : MonoBehaviour
{
    public string Whatplayer;
    Vector3 PlayerPos = Vector3.zero;
    //float AngleRotation = 0f;

    public string whatScript;
    // Update is called once per frame
    void Update ()
    {
        GameObject thePlayer = GameObject.Find(Whatplayer);
        Movement playerScript = thePlayer.GetComponent<Movement>();

        PlayerPos.x = playerScript.transform.position.x + playerScript.chargeX / 10;
        PlayerPos.y = playerScript.transform.position.y + playerScript.chargeY / 10;
        PlayerPos.z = playerScript.transform.position.z;   
      
        transform.position = PlayerPos;
    }
}

This script is attached to a gameobject that is in turn attach to one of the players and makes it so an arrow is following that players movement. Hard to explain really since I didn’t make it, my equally new friend did. Looks like this Screenshot by Lightshot

In the picture you see that I have written what player its following but in the script itself I have to write which scripts variable specifically to use, in this case “Movement”. But I’m trying a bunch of different script and I don’t want to go in and edit the script to the new script. I want to be able to write which script it is supposed to use, similar to the whatplayer field. Is this possible at all?

TL;DR
I want to change “Movement” in the script to a namespace that I can change in the inspector.

Edited that as soon as I posted, thanks anyway :smile:

this is a question, I’m not saying to do this

so you basically want to be able to do something like

public string myType;

void function()
{
    [myType] someVariableName = GetComponent<[myType]>();
}

?

Yes, you’re exactly right.
Instead of using “playerScript” I want to be able to use the script specified in the inspector.