• 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 JustinMeyer · Oct 18, 2017 at 07:09 PM · animatorstate machine

How How can I make a simple combo combat system.

I'v been trying to make a melee combo combat system in the Unity Animator, but I can't seem to get it right. I'm trying to go for a combo system that flows from Hit 1 to Hit 2 to Hit 3, ect, with clicks from my mouse, and if I don't click again it will go back to Idle. How would I go about making this combo attack system in the Animator with C#.

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 BlackShadowPro · Oct 23, 2019 at 07:47 PM

Check this out it may help you a lot: link text

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
2

Answer by MaxGuernseyIII · Oct 18, 2017 at 08:58 PM

I can see why, maybe, you were drawn to animation - there's a state machine in your problem and there's a state machine in the animation stuff.

However, they are different state machines. Animation is about how things look and this state machine is really about how things act.

The state pattern is how we address state machines being a natural component of a problem.

The kind of combo system you are building dictates how you address the state machine.

For instance, if it's a combo system where successive hits have a cumulative effect, then you need a way to detect how many successive hits have been scored in the most recent run. That amounts to knowing when the last hit landed (e.g., from DateTime.Now), how long a time between hits can be allowed before the combo breaks (e.g., with a TimeSpan), and how long it has been since the last hit (e.g., with DateTime.Now - lastHitTime). Those are just example implementation details. A lot of people would choose to use Time.deltaTime or something. I'm not telling you which is right, just that there are different options that will work.

If it's a combo system that lives in the input, as in a well-timed sequence of strikes initiates a choreographed "special attack", then you need something that tracks which potential combos are still available and processes new inputs to narrow that set or detect when a combo has properly been invoked. For most games, you could probably get away with a list of objects that each tracks their own combo state and kicks off the special operation when they are triggered.

If it's a combo system based on the natural dynamics of various moves (e.g., a back-punch is more powerful after having recently landed a front-punch), then you probably are best off with a classic implementation for the State pattern, like you would find on Wikipedia or any other source: A single abstraction has methods for all the different "events" that can be exerted against the combo system and most of those methods return a reference to the same abstraction. This means that every state has an opportunity to handle each event differently and also to control what the new state is after an event has occurred. If you don't want to transition the state machine, you just return this.

Comment
Add comment · Show 3 · 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 JustinMeyer · Oct 19, 2017 at 10:32 AM 0
Share

I'm still new to Unity and I don't exactly know how to do what you said.

avatar image MaxGuernseyIII JustinMeyer · Oct 19, 2017 at 01:10 PM 1
Share

None of these are Unity things. They are C# things and, really, they are just plain program$$anonymous$$g things.

I gave three options based on three possible kinds of game play. If you narrow it down, I can point you toward the right set of resources for the kind of problem you have.

avatar image Dr_GeoFry MaxGuernseyIII · Nov 07, 2018 at 07:47 PM 0
Share

why not give an example...

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

82 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

Related Questions

How to delete a StateMachineBehaviour via Editor Script? 1 Answer

Using Unity's state machine GUI 0 Answers

StateMachineBehaviour.OnDestroy is getting called by SetActive 1 Answer

Building animator blend tree in code 1 Answer

State Machine Behaviour public variable not assignable from editor? 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