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 AlphaTails · May 28, 2021 at 10:59 AM · attacking

How would I make a branching attack system?

I've been looking into experimenting with different ideas, just to see what I can learn and how I could apply it or put a twist on it. One of those is a branching attack system (Think Dust: An Elysian Tail where you can either start a normal attack string, or press the attack button and then another one to do a rising uppercut-esque attack, which can lead into air attacks and the like).

I thought it would be a matter of having, say, an array or list that stores the names of attacks and when pressing another button, it would check the name of the attack and what the current number of button presses in the chain would be. I believe that this could work, however I also feel like it would be incredibly sluggish to work on, and difficult to easily maintain depending on how much would need to be done.

Would this work? Or could there be a far better way to implement this?

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
0

Answer by mevsvader · May 28, 2021 at 04:45 PM

im guessing u want like a combo system so if u press right right up it does a combo for example.

i havent done anything like that yet but if i had to guess i suggest starting a timer when an input is made. for example player pressses right, a timer lets call it righttimer (ik im very creative) starts counting down from lets say 0.7 secs, then you check for another input while the timer is counting down, and if a timer is counting down then do a different attack. that input will start another timer, for example we got inputs right then left, now the righttimer is on lets say 0.5 secs left and lefttimer is on 0.7 secs left. now we check for inputs again and if righttimer > lefttimer and input up, we do attack X, if lefttimer > righttimer do attack Y.

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

Answer by Earthshine · May 28, 2021 at 09:12 PM

It is not the definitive answer and not even an advice. It is what I would try to do if I was going to make a branching attack system. I don't believe I am competent enough to suggest the best practice for developing a complex system. I would like to discuss my wild guess however.

I would try to make such a system using unity animator controller state machine and animation events. There are several pros and cons compared to writing all the logic down in code.

Pros:

  1. All the combos and all the branches are clearly visible as well as the whole 'attack tree'.

  2. It is easy to add, remove and modify transitions between attacks.

  3. Easy to modify all the timings and sync function calls with animation: you may call DealDamage() event in exact frame you want, then listen for the GetKeyDown() needed to continue the combo for 0.5 s and then stop listening before recoil ends.

  4. You'll need to make a lot of states for character animation in such a game anyways. Why not use it as a scaffolding for the attack system instead of the other way around.

Cons:

  1. Animator window UI is suboptimal to say the least. You'll go through lots of unnecessary mouse clicks. You can't see transition parameters without clicking on it, you can't see what animation is in the state without clicking on it, you'll need to locate animation file in asset hierarchy to switch off the looping every time and so on.

  2. Animator events are not pretty either. Even more clicks, even more 'blind' UI, function calls may only receive one parameter - a limitation that is hard to circumvent sometimes.

  3. Easy to mess up and hard to debug. You wouldn't know about a typo in parameter name or a wrong function you selected from dropdown menu until you try it out in the play mode. Locating the error in code or animation becomes even more time-consuming.

  4. Animator-based system is more performance-sensitive that script-based.

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

120 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 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 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 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 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

Attack cooldown not correct? 2 Answers

I only want the attack to register once. I'm sorta new to Unity and any help would be greatly appreciated! 1 Answer

Enemy AI problems 2 Answers

How can I make an event happen every 2 seconds in the OnTriggerStay void? 2 Answers

Spinning attack! 3 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