• 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
4
Question by stepcross36 · Mar 09, 2010 at 08:05 AM · inputcombo

Help me with the script on doing combo atk

hi everyone, its my first time to ask question here and im pretty much new in unity 3d but i manage work well in my first game... ive already did many tutorials and read some questions and answer here in forum... there is 1 thing i havent found is that...

i dont know the script or i dont have any idea how do i apply in my game, when doing some attacks but with different atk moves but not randomly doing atks instead a combo atk like in SPIDERMAN3, DEVILMAYCRY or ANY kind of action game... hope u get i mean here (cuz im bad in english and im not english guy hehe)... could anyone help me pls?

ive tried asking some ppl and even my professor in my school but it seems they dont know either... but in my mind it tells me i should use an array to call each atk constantly... am i right? pls help! very many thanks! more power UNITY USER!! =D

Comment
Add comment · Show 1
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 Lipis · Mar 09, 2010 at 09:59 PM 1
Share

It's not very clear what you are asking..! Do you want somehow to catch for example if a player pressed a specific sequence of buttons? (Up > Down > Up > Left for example)

3 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by Lipis · Mar 13, 2010 at 01:16 AM

Here is a simple example on how can you do it.

  1. Create new Javascript and rename it to PlayerAttack
  2. Copy/paste the below code into it
  3. Drag the PlayerAttack script to your First Person Controller
  4. Press the Play button to see it action

var fireRate: float = 2; var comboNum: float = 3; private var fired: boolean = false; private var timer: float = 0.0; private var comboCount: float = 0.0;

function Update () {
if (Input.GetButtonDown("Fire1")) { if (!fired) { fired = true; timer = 0.0; comboCount = 0.0; Debug.Log("I served a punch!"); //Do something awesome to deliver a punch! } else { comboCount++; if (comboCount == comboNum) { Debug.Log("I did a combo!");
//Do something awesome for the combo! } } }

 if (fired) {
     timer += Time.deltaTime;
     if (timer > fireRate) {
         fired = false;
     }        
 }

}

The basic concept of this approach is that if you pressed Fire1 you are starting a timer, and as long as the timer is less than fireRate (2 seconds in this example) you can't deliver more punches. Now during this time whenever the Player is pressing the Fire1 button you are increasing the comboCount variable. If it's exactly comboNum (3 in this example), you are ready to execute your combo function.

See also documentation for Input and Time classes.

Comment
Add comment · Show 1 · 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 Bugger42 · Apr 04, 2014 at 06:14 PM 0
Share

hey how would I make it so that it animates an attack for each combocount?

avatar image
1

Answer by stepcross36 · Mar 11, 2010 at 07:14 AM

what i mean is... when u press mouse1 button then it punch and if u continue or repeat press the mouse1 button it will make a combo atk instead a single punch

example... in devil may cry, when u press the atk button 3x, its doing a combo with 3 slash

Comment
Add comment · Show 1 · 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 Lipis · Mar 13, 2010 at 01:18 AM 1
Share

please don't not post these kind of questions as answers.. use comments ins$$anonymous$$d or edit your question for giving a better description on your problem. Check the http://answers.unity3d.com/faq on how it works.. because it's not another forum.

avatar image
0

Answer by stepcross36 · Mar 18, 2010 at 09:52 AM

tnx! this help me a lot! now i can apply this in my 3rd person controller! tnx!! great help!

Comment
Add comment · Show 1 · 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 Lipis · Mar 18, 2010 at 11:08 AM 1
Share

@stepcross36 I updated the answer but don't post comments as answers.. Use the add comment button for these kind of posts.. the post area is only for answers! good luck

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

2 People are following this question.

avatar image avatar image

Related Questions

multiple inputs 2 Answers

Key Combo system. where I am going wrong with this? 2 Answers

What is the best way to store User Input and use it later with the new input system? 0 Answers

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Input keycode string not working 2 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