How do I regroup objects with unique values?

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hello, I am currently making a top-down shooter game (planning to be in multiplayer). In this game, there are 4 weapons, 2 classes (Assault and Heavy), and 2 teams (Light and Dark). I made a loadout menu that let you choose bewteen all those parameters (class, team, weapon). The problem is that it makes too much conditions at time (give you an example below):

    Every tick

    If Weapon=1 => Set Weapon1 angle to Mouse.X, Mouse.Y

    If Team="Light"

    If Class=1 => Set Weapon1 position to Light_Assault__Soldier

    If Class=2 => Set Weapon1 position to Ligh_Heavy_Soldier

    If Team="Dark"

    If Class=1 => Set Weapon1 position to Dark_Assault_Soldier

    If Class=2 => Set Weapon1 position to Dark_Heavy_Soldier

    And it goes for If Weapon=1,2,3,4... Moreover, I'm planning to mirror the soldier if the Mouse.X<Soldier.X

    How do I regroup soldiers into 1 thing and weapons into another thing so that I don't have to write thousands of lines of codes?

  • You will probably be able to cut down the number of conditions required with some careful grouping of objects into containers and families.

  • How could I use the container?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If all of your soldiers use a weapon then I'd consider adding them in a container together, so when you pick a soldier its weapon is automatically picked.

    I'd also pin (position only) the weapon to the soldier so that you don't have to keep repositioning it.

    If you do use a container then rather than having a family it might be better to just have a single soldier object and set the team and class with a variable. You would have different animations for the teams and classes on the one soldier object. Same for the weapon: a variable for type, different animations for each type.

    On start set variables and animations for each soldier/weapon then pin the weapon to the soldier.

    Every tick for each soldier set weapon angle to Mouse X,Y.

    The pin should then take care of all the repositioning.

    On change of direction, unpin the weapon, mirror the soldier, mirror the weapon, reposition and repin.

  • I'll try it thanks bud!

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