How do I Setup directional based attacks

0 favourites
  • 2 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Project is a sidescrolling fighting game

    Currently I have 4 playerboxes used as hitboxes for each player. I have 14 characters that are positioned ontop the those playerboxes. Right now I have 4 directional based melee attacks (punch left, right up down etc) but I'm trying to decide how to go about making 4 more attacks that are more complex and unique to each character. What would be a good way to setup a function for this? So when a player is holding left and pressing C they will do the associated attack for the character they are playing as

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Prazon,

    Hopefully I'm interpreting this right, it sounds like there are 14 different selectable characters in the game, and you have a generalized character rig setup that has a spot for the selected character in the middle, and then 4 boxes situated around the character, representing attack zones to the left, right, top, and bottom of the character.

    You want a control input, like Towards + C, to trigger a unique action depending on the chosen character.

    Two options come to mind, global variables is one, and a callback function system is the other. The global variable method is easier but a little less flexible, though it should still work just fine in this case.

    Global variables:

    You can use a global variable to store the name of the character chosen by the player, and only trigger that character's attack if their name is found in the global.


    * Event: If keyboard pressed Left + C.

    * * SubEvent: If global characterName = "lulu". -- Action: Call function "luluShield".

    * * SubEvent: If global characterName = "veigar". -- Action: Call function "veigarStun".

    * * SubEvent: If global characterName = "teemo". -- Action: Call function "teemoSelfDestruct".

    Callback functions:

    You can create a Dictionary object, that maps control input events (Dictionary keys) to function names (Dictionary values). At the point that a player selects a character, you can populate the Dictionary with the chosen character's functions. These functions will execute the character's actions.


    * Event: Player chooses "lulu".


    Add to Dictionary key = "Left+C", value = "luluShield" .

    Add to Dictionary key = "Right+C", value = "luluSpeedUp".

    etc ...

    * Event: If keyboard pressed Left + C. -- Action: Call function ( Dictionary.getValue( "Left+C" ) ).

    Note: Dictionary.getValue( "Left+C" ) will return "luluShield", which we added earlier, and so the action evaluates to [Call function ( "luluShield" ).]

    * Event: On function "luluShield". -- Action: Execute the stuff that's supposed to happen when Lulu uses her shield ability.

    Hope that helps.

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