Character Selection
I'm developing a game that uses different characters, with a similar kind of function to goat simulator, the characters all have base movement and abilities. But all of them have special moves which differ a lot.
Currently I'm using a main object with movement scripts, then using a selected character int as an index for selecting character meshes in children, and particles etc. I've just started trying to use scriptable objects for setting player stats, but I'm not sure how to 'index' which scriptable objects to use. I don't really want to use a switch or ifs. Another problem is that I'm using local multiplayer so I can't use one scriptable object for both players. As it 'attaches' to an object to invoke the appropriate function from the matching ability script on the character.
What I don't know if whether to have the characters as separate objects with the movement scripts, etc., as well as a script for the abilities. Though I'm not sure again how to 'index' the characters, not wanting to write a couple hundred lines with a switch statement.
Or have one big object like I have now.
I don't really have much experience as a beginner, so it would really help if you could help or point me in the right direction.
Also I do have 'numbers' for each character, from the selection screen and being used right now for choosing which child mesh to activate.
Ah, that's an interesting topic!
I would say that you want to use the Animator component a lot. It allows you to have different "characters" with Animator components on them, which will receive triggers and other parameters, but will do specific stuff with them.
In regards to "switching", did you consider having a "type" enum with a type property that would catch the change and trigger events. This is something I do quite often, I find it handy a pretty powerful.
like :
public enum TYPE {Archer, Soldier, Wizard, Villager};
public delegate void typeChange(TYPE type) ;
public event typeChange typeChanged;
private TYPE _type;
public TYPE Type
{
get { return _type; }
set
{
if (value != _type)
{
_type = value;
if (typeChanged != null)
typeChanged(_type);
}
}
}
Your answer
Follow this Question
Related Questions
How do you set Prefabs into a GameObject array that will activate/deactivate when called? 1 Answer
Problems with instantiating 1 Answer
PrefabUtility.RevertPrefabInstance() not working 2 Answers
I need help finding the index of an object in a list. 1 Answer
If instantiate prefab is selected how can i change the color? 1 Answer