I'm trying to assign player inputs for new spells unlocked by a player, I'm using Unity's Input system. When a player selects a spell it subscribes the relevant binding to the spell's cast method (e.g. 'CastFireball()')
I want to replace the manual typing of "CastSPELLNAMEHERE()" on each spell with a string variable represented by _spellMethodID. I've been trying all sorts and googling from dawn to dusk and I can't get it to work. >:(
playerInput.FindAction(_spellID).performed += context => CastFireBall();
public void CastFireBall() { Debug.Log("fire"); }
I'd LIKE to be doing it like this instead:
string spell_methodID = "CastFireBall"
playerInput.FindAction(_spellID).performed += context => _spellMethodID;
public void CastFireBall() { Debug.Log("fire"); }
Help!