How do I efficiently make multiple characters to select from

0 favourites
  • 8 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Should I make one object that has animations for all the different character types and change animations based on which character the player selects? Or should I make an object for each character and destroy the rest when the player chooses one of the characters? Or does it matter?

    Also, is it better to make character stats a global variable or incorporate it as an instance variable for that object?

  • This depends on a few things:

    Can the player change his character during game?

    Does a character have several animations (like jump etc.)?

    And I always prefer instance variables over global variables. Your project is more clear than using too many global variables. (Image you put everything in a global variable and later in the game you have hundreds of them... wow...)

  • The player will not be able to change characters during the game. It will be a Diablo-like system in which each character has different skills.

    My question is, is performance impacted if one object stores all that information? It just feels easier to make one object and switch animations based on a variable like characterChoice.

  • I haven't tried it yet, though I intend to. But the way I would do it is that I would add a global variable called "character_choice" or something like that, then check for that in the game. So when the player picks a character, the game will update the variable accordingly. The character itself can have local variables and all that, so the global variable is just to see which one is picked.

    Or a really, really simplified version:

    What character is picked? If character A, spawn character A and give the controls to him/her. If character B is picked, spawn that one instead, and give the controls to him/her.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could have a "spawner" object spawn the correct sprite at the correct position based on the player choise. (or enter frame depending on what effect you want. (so yes this is destroy/create method)

    You could have one sprite have everything but be used only for the "character select screen" and just swap "animations"

    Depends on what you want to achieve. I have used both methods so far its a bit more dependent on need than on actual performance.

    If you use something like spriter which has a plugin for c2 you can setup your animations and a set of "skins" check their stuff maybe you get some ideas too. I'm planning on using that as soon as I'm done with the current projects I'm working on.

  • Thanks for the input everyone!

  • I've been dealing with a character swapping issue for several months now, and I was wondering if we could examine methods for doing so in-game during play without pausing. My specific scenario is as follows:

    I have three character containers at all times. At any moment, however, these can be switched to any one of four character designs (which involves several sprites being swapped out). To give a drastically oversimplified example: Mario gets replaced by Luigi, Peach, or Toad on queue, and each character involves a unique set of costume accessories in child sprites which also have to get swapped out.

    The amount of animations involved and the possibility of adding more in later makes simply stacking everything into one sprite's animations unwieldy and inextensible. (As was the suggestion here).

    The fact that UID's can't be predicted and IIDs can be dynamically updated makes these unreliable, as I cannot talk to any of my objects once I destroy one instance and replace it with another. I've managed to use a Local variable number to refer to the characters with limited success, but I can't figure out how to reassign the number to an object after swapping. For example:

    Character IID 3 is assigned localVar value 2.

    Character IID 3 needs to be swapped out, and so is destroyed.

    New character is immediately swapped back in, but the IIDs are all wrong now and I can't figure out how to specify the new instance to reassign localVar value 2.

    I've also seen this tutorial, but that scenario seems to involve switching between objects which never get removed or added back to the layout, and all exist simultaneously.

    I'm starting to think in circles. Am I simply approaching this from the wrong mindset?

    I've tried making use of Families and Containers. Unless I'm mistaken, containers don't allow you to selectively destroy/spawn one single child sprite. Families, meanwhile, suffer the same UID/IID limitations as their Sprite children.

  • Bumping. Not sure this topic ever updated in the forum list.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)