Monday 29 December 2014

Unity Fighting Game Combo System !

Over the Christmas period I've retreated to my home in Manchester for a chance to chill with my family and relax. It's actually been great for my work flow, I've managed to get a fairly big chunk of work done on Tempremental and sorted out some plans for my coursework when I return to Leeds.

But as I was saying, the fairly big chunk of work :
After a few days of slaving gradually removing distractions & getting on with my programming I've managed to create the combo system for the game which was one of the biggest parts of the coding that handles input. I've set up a class on the player which handles the input of the user and sends the button presses to an external class on the player called CommandReceptor.

CommandReceptor
The command receptor has a function which takes arguments representing the buttons current states and then submits them to a list called inputList, this function then checks how many moves are stored in the list and if it's above moveCache then the oldest entry is deleted (this means there is a speed limit that the sequences need to be input by). 
// stores commands 
 public void ParseCommands(float horiz, float vert, bool xButt, 
                           bool sqrButt, bool triButt, bool oButt)
 {   
  List cmds = new List(){horiz, vert, xButt, sqrButt, triButt, oButt};
  inputList.Add (cmds);  
  if (inputList.Count > moveCache) // if input list has backlog of over movecache then removes earliert input
  {
   inputList.RemoveAt(0);   
  }
  MoveCheck();
 }

From there it runs a sequence which cross references every entry in the inputList by every possible sequence which is stored in list possMoves. This checks to see if there are matches and if it does; increments a sequence counter & removed all moves from the possMoves list that don't match the current sequence. If the sequence counter reaches the length of the move, the move is performed, the inputList is wiped and the possMoves list is reset. The information on the move is sent back to PlayerControls and is dealt with from there. 

// runs though arrays of moves to check if there is appropriate sequence 
 void MoveCheck() 
 { 
  for (int i = 0; i < inputList.Count; i ++)
  {
   bool shouldExit = false; // exits function if finished move           
   
   for (int j = 0; j < possMoves.Count; j ++)
   {    
    if (ArrayCheck(inputList[i], possMoves[j][possMoveCount]))
    {    
     possMoveCount ++;    
     if (possMoveCount >= possMoves[j].Count) 
     {       
      possMoveCount = 0;  // clears how far you are in sequence    
      PerformMove(j);  // does move using number of list as array 
      inputList.Clear(); // clears moves archive
      shouldExit = true;  // stop function 
      break; 
     }       
     CleanPossMoves(j,possMoveCount); // also tells the sequence    
    }    
   }
   
   if (shouldExit) // exits function if condition met
   {
    break;   // exits from main loop       
   }   
  }
  MakePossMoves();
  possMoveCount = 0;  
 }
So at the moment I have the ability for directional moves & directional combinations. I think all I really need now in terms of the combo system is to develop a state mechanism that allows combos by performing moves based on what the last move was and how long ago it was performed. I still regrettably don't have a tablet and so can't really create any more assets to work with (at least neater than a shaky stick figure or silhouette) but when I make any headway I'll be sure to update the blog.

So yeah, that's my post Christmas update and expect to see more in 2015, Happy New Year guys. 

P.S: I decided to make a github repository for this project so people could  see the code if they were interested https://github.com/IzaacBarratt/tempremental.



Wednesday 17 December 2014

Temperamental update 2

I've been having difficulty creating assets at the moment because the tablet I was using to draw and animate has selfishly decided to stop working. Fortunately I had already been able to create a simple jump, walk and idle sprite for one of my contestants and so have been able to play around with the mechanics of character movement.

I've created the movement physics, wall collisions, dashing, gravity, and wall sliding/holding. Messing around with the drag and friction on the floor so I can get a feel for how responsive the player can interact with the game but other than that I don't think I'll be able to do much until I get back to animating assets. 

I'm slowly coming up with a more complete idea in my head of how the game is ultimately going to play out but until I have a working demo I think I'll leave them in my head.