1
\$\begingroup\$

What's the best way to make a character selector similar to DOTA 2 game, but instead of having an unique animation for the hero it just displays the sprite of the character, the game is 2D.

public GameObject[] gCharacters;
private float[] characterScales;
public GameObject Image;
int i = -600;
public Sprite sprite;

void Start()
{   
    characterScales = new float[gCharacters.Length];
    for (int x = 1; x <= gCharacters.Length; x++)
    {
        GameObject inst = Instantiate(Image, Image.transform.position, Image.transform.rotation) as GameObject;
        inst.GetComponent<RectTransform>().position = new Vector2(gameObject.GetComponent<RectTransform>().position.x + i, gameObject.GetComponent<RectTransform>().position.y);
        inst.transform.parent = transform;
        sprite = gCharacters[2].GetComponent<SpriteRenderer>().sprite;
        Image.GetComponent<Image>().overrideSprite = sprite;
        i += 200;
    }
}

For the sprites to be displayed which is my main goal here I've used the IMAGE UI.

\$\endgroup\$
  • 3
    \$\begingroup\$ This is a very open-ended question. We can help address specific problems you encounter, but right now this just sounds like "write this feature for me." What have you tried? \$\endgroup\$ – jhocking Dec 28 '16 at 21:06
  • \$\begingroup\$ This is what I've tried and I'm still stuck on displaying images, I was hoping for some advice like "You shouldn't use this, this way it's better" I don't need written code, just someone to point me to the right direction \$\endgroup\$ – Lendrit Ibrahimi Dec 28 '16 at 21:18
  • 2
    \$\begingroup\$ If you just want advice, I'm afraid your in the wrong place. We take direct questions, but refrain from discussion or opinion based questions. You might find what your looking for in chat. \$\endgroup\$ – Gnemlock Dec 28 '16 at 23:03
  • \$\begingroup\$ You're indeed very misunderstanding, anything that could help, even pure code would do, I just said that I don't want none to do "write a feature for me." all I want is something that would help me move forward. \$\endgroup\$ – Lendrit Ibrahimi Dec 29 '16 at 19:57
  • 1
    \$\begingroup\$ What problem have you encountered with this method so far, or what behaviour do you want that it's not giving you? The code you've shown so far looks like a reasonable start, so it's not clear to us what kind of help you need. There's no one universal way to write a character selector, so if the way you're writing it works for you, then you don't need feedback from us. If what you have isn't working for your needs, then edit your question to be very specific about the particular problem with it that you're trying to solve. \$\endgroup\$ – DMGregory Dec 31 '16 at 22:52

Browse other questions tagged or ask your own question.