Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Heffalus · Jul 29, 2015 at 09:26 AM · c#mecanimattackblend treecombo

mecanim blend tree attack combo

So im trying to make attack combos, i think using a blend tree would be the solution but i dont know how to do it, i can set up a blend tree, but im lost on the scripting of the combos. Its gonna be like a hack'n slash, the user can spam the attack button to do consecutive attacks, and after the third a pause. If the user does not push the attack button withing a certain amount of time after the previous attack it resets.

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 Polymo · Jul 29, 2015 at 10:01 AM 0
Share

I dont think it's exactly mechanim related, you would still just transition between regular animation states. $$anonymous$$ore important would be how you handle the combos in your controller/Input scripts. I would suggest having classes with arrays of actionTypes (and finisher) as combo-templates And an ExecuteAction(Actiontype) method on your character. Then your character keeps a list of the last executed actions (with a certain timeframe before clearing it) and if these actions match to some combo templates, collect the templates that also match and do that after each player action until there's one left and execute its finisher action.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Positive7 · Jul 29, 2015 at 10:06 AM

Something like this?

 using UnityEngine;
 using System.Collections;
 
 public class test3 : MonoBehaviour {
 
     public float time = 3.0f;
     public Animator anim;
     public float Attack;
     public bool startTimer;
 
     void Start () {
         anim = GetComponent<Animator> ();
     }
 
     void Update () {
     
 
         if (Input.GetButton ("Fire1") && time > 0) {
             Attack++;
             startTimer = true;
         } else if (time <= 0.0f) {
             Attack = 0.0f;
         }
         anim.SetFloat ("FloatName", Attack);
 
         if (startTimer) {
             if(time >= 0){
                 time -= Time.deltaTime;
             }else if (time <= 0){
                 time = 3.0f;
                 startTimer = false;
             }
         }
     }
 }

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 joelplourde · Mar 04, 2017 at 12:52 AM 0
Share

I must admit that you algorithm is the best I've seen so far from looking at other "combo attack script". Simple, but efficient.

Gratz m8.

avatar image
0

Answer by MrTindervox · Jul 11, 2018 at 01:05 PM

 if (Input.GetButton ("Fire1") && time > 0) 
   {
     Attack++;
     startTimer = true;
   } else if (time <= 0.0f) {
     Attack = 0.0f;
     time = 3.0f;
     startTimer = false;
   }
 anim.SetFloat ("FloatName", Attack); 
 if (startTimer) {
   timer -= Time.deltaTime;
 }

Pretty sure this would yield the same. Plus <= in else if would never trigger cause >= is in if statement.

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

24 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Mecanim Making an NPC walk 1 Answer

How to control damage output. 0 Answers

How to get default animation for layer 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