How do I determine all conditions of Character 1 to Character 2 without copy and paste everything?

  • I think it's easy to understand... it's exactly what the question says: "How do I determine all conditions of Character 1 to Character 2 without copy and paste everything?"

    For example, if I already have events that will work on Character 1, I want it to happen with Character 2... controls, how it will die, etc...

    I hope someone can help me...

    Thanks!

  • I think you need to use a family. Instead of having two almost identical blocks of code for two objects, it's much better to combine them into a family.

    scirra.com/manual/142/families

    scirra.com/tutorials/535/how-to-upgrade-an-object-to-a-family

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! Thank you so much!

  • Im just going to jump in here as its related:

    So at the moment i have a family object called "player" in wich i have 2 sprite objects "player_1" and "player_2"

    "player_1" inside the family has an instance variable - selected_player = 1

    "player_2" inside the family has an instance variable - selected_player = 2

    The family itself doesnt have an instance variable set - as i dont know if the individual object from the family needs to have the instace varibale or the family itself.

    I also have a global variable called selected_player = 0

    When you select player1 from the character selection layout i set that variable to 1 or 2 based on the selection.

    At the start of the game layout i create the player object and place it at specific coordinates.

    So the question is, how do i get player_1 or player_2 to appear based on that global variable.

    Hope it makes sense.

    At the moment they show up randomly.

    Thank you so much!

  • mrmlabs On start of layout if global variable selected_player=1, create sprite player_1, otherwise create sprite player_2. Or you can use "Create by name" action, and create object "Player_"&selected_player

    I also suggest moving the instance variable selected_player to family level (see the link I posted above on how to do this). This will allow you to use this variable in events with the family object. For example, you might have something like this:

    On bullet collision with PlayersFamily: 
    	PlayersFamily.selected_player=1 -> Spawn green particles
    	PlayersFamily.selected_player=2 -> Spawn blue particles
    
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)