- Home /
Inspector references and scripts with the same name
Hello!
I have a question regarding inspector references and scripts with the same name.
I have a script called "EnemyClass", which is a class for all types of enemies that has functions that are used by all types of enemies. In this script I have an inspector reference to the enemy's AI, which is called "EnemyAI".
However, not all these enemies have the same AI. So I thought creating of namespaces for each new AI and retaining the script name "EnemyAI" so that the inspector reference on the EnemyClass script can still pick up the reference correctly.
That doesn't seem to work, so I know namespaces isn't something I can use. I don't want to create multiple EnemyClass scripts for each EnemyAI, cause that would be redundant as the only difference between the classes would be the reference to another EnemyAI script.
I thought of having empty references to ALL EnemyAI's, and then using an 'if' statement based on the Enemy's unique ID, and use the correct EnemyAI script, but that felt really cumbersome.
Does anyone have the best practice to go about doing this? Or is there no better way to approach this situation?
Thanks!