Setting Input windows or queuing user input

Hey guys,

Got another question for you all.

We’re coming to the final two weeks of production on our project, “Soulshift” and we’ve made huge strides here all thanks to you helpful unity members. We’re now polishing our game before we present it to the industry professionals that will visit our school on our Industry night and we’re now trying to re-visit our combat system and trying to make it more stream-lined.

I was just wondering if there was any way that I could possibly queue user input, as our game is a Hack’n’Slash game. We currently have a 3-hit melee combo and we want to make it so that if user’s spam input. They character will do the 3 hit combo, wait slightly and then continue the combo again like normal, if the user continues to spam more input.

Is this difficult to achieve? Because, I’ve been looking into using the animation window so that I can call animation events in order to set controlled functions within our combat system, but it doesn’t seem to be the best way to make it work.

Any and all help would be appreciated! Please help us make this game the best it possibly can be. I’m thinking of making it a downloadable .exe for everyone to download and try once it’s complete. We would love to have feedback on what we accomplished and what we can possibly improve upon.

Thanks!

Condor

Definitely possible. Easy to implement as a queueueueue using List -

var queue : List.<String> = new List.<String>();
...
if ( Input.GetButtonDown("Attack") ) {
  queue.Add( "Attack" );
}
...
switch case queue[0]:
  case "Attack": ContinueCombo();
...
queue.RemoveAt(0); // removes the item at index zero and shifts the rest

Here’s the Combo.CS script.

using UnityEngine;
using System.Collections;

public class Combo : MonoBehaviour
{
	public float attack1Time = 1.2f;
	public float attack2Time = 1.2f;
	public float attack3Time = 1.2f;
	float minTimer = 0.6f;
	float maxTimer = 0.0f;
	public float buffer = 0.4f;
	
	public TP_Animator character;
	public ThirdPersonController Controller;
	
	public GameObject currentArmor;
	
	public GameObject whiteArmor;
	public GameObject blackArmor;
	
	public katCollision katCollision;
	public Collision_clay clayCollision;
		
	int fired = 0;
	
	public AudioSource katanaswing1;
	public AudioSource katanaswing2;
	public AudioSource katanaswing3;
	public AudioSource claymoreswing1;
	public AudioSource claymoreswing2;
	public AudioSource claymoreswing3;

	void Start ()
	{
		katCollision = GetComponentInChildren<katCollision>();
		clayCollision = GetComponentInChildren<Collision_clay>();
		Controller = GetComponent<ThirdPersonController>();
		
		character = blackArmor.GetComponent<TP_Animator>();
		currentArmor = blackArmor;
		
	}
	
	// Update is called once per frame
	void Update ()
	{
		
		
		
		minTimer -= Time.deltaTime;

		maxTimer -= Time.deltaTime;

		//reset if player hasn't hit button in time
		if (fired >= 1) 
		 {
			
			if (maxTimer < 0) 
			{
				fired = 0;
				
			}
		}
		
		if (Input.GetButtonDown ("Fire3")) 
		{
			
			Controller.isattackingTime = 0.9f;
			
			if(minTimer <= 0)
			{
				
				switch (fired) {
		
				
					case 0:
						{
							minTimer = attack1Time - buffer;
							Debug.Log ("min timer " + minTimer);
							maxTimer = attack1Time + buffer;
							Debug.Log ("max timer" + maxTimer);
								
							fired = 1;
//							Debug.Log("attack 1");
							
							if(currentArmor == blackArmor)
							{
								katCollision.comboNumber = fired;
								character.Attack();
						        katanaswing1.Play ();
							}
						
							
							if(currentArmor == whiteArmor)
							{
								clayCollision.comboNumber = fired;
								character.AttackClaymore();
						        claymoreswing1.Play();
							}
						
							
								
							break;
						}
					case 1:
						{
							minTimer = attack2Time - buffer;
							Debug.Log ("min timer " + minTimer);
							maxTimer = attack2Time + buffer;
							Debug.Log ("max timer" + maxTimer);
							
							fired = 2;
//							Debug.Log("attack 2");
							
							if(currentArmor == blackArmor)
							{
								katCollision.comboNumber = fired;
								character.Attack1();
								 katanaswing2.Play ();
							}
						
							
							if(currentArmor == whiteArmor)
							{
								clayCollision.comboNumber = fired;
								character.AttackClaymore1();
								claymoreswing3.Play();
							}
						
							break;
					
						}
					
					case 2:
						{
							minTimer = attack3Time - buffer;
							Debug.Log ("min timer " + minTimer);
							maxTimer = attack3Time + buffer;
							Debug.Log ("max timer" + maxTimer);
							
							fired = 3;
//							
						
							if(currentArmor == blackArmor)
							{
								katCollision.comboNumber = fired;
								character.Attack2();
						        katanaswing3.Play ();
						
			                  
								
						        
						
							}
							
							if(currentArmor == whiteArmor)
							{
								clayCollision.comboNumber = fired;
								character.AttackClaymore2();
								claymoreswing3.Play();
							}
						
								
								break;
				
						}
					}
				}
			}
		
		
		
		}
	
	
}