In this game I’m working in I want to make a reusable script that contains a reference to the PlayerFollow script. But depending on the nature of the level, I use different PlayerFollow scripts. Because of this, I have to write a different script for each Player Follow script. To get around this I tried using a public String for entering the Type of the Script Component I’m referencing from the editor. But it does not work as intended.
Is there a better way? Thanks!
My code:
.
public string ScriptType;
//I would add the Type of the script through the editor
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
other.GetComponent<ScriptType>().enabled = false;
}
}