Hi,
I am trying to make a POE/Diablo type game and am running into some logistical trouble. I am loading an active spell onto a button via gameobject. i need to get the component of the spell on that game object. there are a bunch of spells and i was hoping to not have to do this:
if(getComponent<FireBall>()){
Cast();
}
if(getComponent<RaiseDead>(){
Cast();
}
ect times way too many...
I was hoping i could pass a string as the component type, something like this…
public string componentName
spell.GetComponent <componentName>().Cast ();
i know the docs give an example…
HingeJoint hinge = GetComponent("HingeJoint") as HingeJoint;
but it requires the name of the component to be hard coded in for example this also would require way to many if statements.
FireBall activeSpell = GetComponent("componentName ") as FireBall ;
I’m stumped and i was wondering if anyone had any good ideas.