Getting a Script without setting a variable to the script name

Hi,

I am making a script that can be used in multiple gameobjects, but requires a different script for different gameobject. For Example, a player would have a movement script input and an enemy would have AI script. This is what i am trying to achieve:

Script Movement;

if (transform.name == "Player")
     Movement = GetComponent<MovementScript>();
else if (transform.name == "Enemy")
     Movement = GetComponent<AIScript>();

How can this be done?

Don’t think so, you have to think more object oriented for these kind of things.
I wrote an example for beginners how to manage item structures, ArmedUnity.com is for sale | HugeDomains

Same can be used for enemies for finding out the type.
When you know the type you can use good old switch case.

This will work for simple things.

private void HitObjectHandler(GameObject go){ //receive object from ray hit (example)
    switch(go.tag){
    case "Npc":
        NpcType npcScript = go.GetComponent<NpcType>();
        FindType(npcScript.index);
    break;
    }
}

public void FindType(short arg){
    switch(arg){
        //Player
        case 0:
        Debug.Log("its a player");
        break;
        //Zombie
        case 1:
        Debug.Log("its a dead meat");
        break;
        //Ninja kitten
        case 2:
        Debug.Log("its a ninja");
        break;
    }
}