I need to change the projectile type as user clicks a button.
I have used this script but it cannot assign my prefab to “projectile” variable.
I even tried Resources.Load()
and GameObject.FindWithTag()
help please!
if (Input.GetButtonDown ("Fire2")) {
if (projectile.transform.name == "cannonball") {
projectile = GameObject.Find("rocket");
}
else {
projectile = GameObject.Find("cannonball");
}
print(projectile.transform.name+ " is selected!");
}