Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Condore · Nov 07, 2012 at 03:08 AM · inputanimationsmeleecombatqueue

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
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Loius · Nov 07, 2012 at 03:28 AM

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
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Condore · Nov 07, 2012 at 03:58 AM 0
Share

Could you explain this is a little more detail? I really appreciate the code snippet!

How can I set it so that it possibly remembers the last 3 times the anims been called?

avatar image Loius · Nov 07, 2012 at 07:03 PM 1
Share

But don't you already have it doing the 3-hit combo? That's a whole 'nother subject, honestly, but I can try.

You need a concept of "when can the user press a button to continue the combo". While within that time frame, if queue[0] is "attack" and the combo counter is less than three, then continue the combo and increase the combo counter.

You might have something like this:

 function Start() { StartCoroutine( AttackListener() ); }
 
 function AttackListener() {
   var continueTimes = [ [0.0,$$anonymous$$athf.Infinity], // for step 0 - not attacking - can hit key at any time
                         [0.5,1.0],   // for step 1, must hit key between 0.5 and 1.0 seconds
                         [0.7,1.1] ];
   var comboStep : int = 0;
   var currentTime : float;
   while ( 1 ) {
         currentTime+= Time.deltaTime;
     if ( queue.Count > 0 ) {
       if ( queue[0]=="Attack" && currentTime >     continueTimes[comboStep][0] && currentTime <     continueTimes[comboStep][1] ) {
         queue.RemoveAt(0);
         continue = true;
       } else { // they pressed not-attack, so stop the combo
         continue = false;
       }
       if ( continue ) { comboStep++; PlayComboStep(comboStep);     }
       else { StopComboStep(comboStep); comboStep = 0; }
     }
     yield;
   }
 }
avatar image Condore · Nov 07, 2012 at 07:31 PM 0
Share

This is interesting, I never actually thought about doing it this way. $$anonymous$$y combo script is quite basic compared to this... Haha.

I'm going to try to implement what you wrote here, it's going to take me awhile but this is exactly what I'm looking for. :D

Also, here's my combo script in C# so you have an idea of what we already have in place.

avatar image Condore · Nov 09, 2012 at 11:40 PM 0
Share

I figured it out! Thank you so much for the help! :)

avatar image
0

Answer by Condore · Nov 07, 2012 at 07:31 PM

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;
                 
                         }
                     }
                 }
             }
         
         
         
         }
     
     
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Melee Combat - Collision Detection 2 Answers

Melee combat, sphereoverlap not working 1 Answer

i need help with my attack point 2 Answers

Localmotion head spinning. 0 Answers

Logic behind multiplayer melee attacks? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges