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 Lboy · Jan 08, 2013 at 04:16 PM · charactercontrollermecanimcontrolfighting

Creating a fighting system with mecanim

So i have been working with Mecanim to create my own character controller, I have the basic movement down to a t, but im having trouble trying to create a simple fighting system with 4 main animations; kick 1/kick2/punch1/punch2.

I want to create a simple blend tree that will blend the animations if and when they are pressed within seconds of each other. But how should this be set up?

Should I add 4 Bool's in the parameter box (each of the animation motions) and have this called upon similiar to the jump feature in the Mecanim Tute? Or am i trying to make something more complicated than it needs to be?

I have this line of code to activate the move(s), I copied and pasted with minor changes for every other animation file. I tried this out with my 4 Bool parameters in place and gave it a transition too and from the locomotion blend tree and the idle state but it didnt play the animations I was trying to activate with the corresponding keys.

if(Input.GetButtonDown("O")){ animator.SetBool("Punch1", true );}

I have basically followed the steps of the main Mecanim Tute (the 40min video on youtube) so my characters animator is layed out exactly like that using the BotCntrl script which i have modified with 4 lines of code, like the example above.

any help/advice what so ever would be greatly appreciated

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Itinerant · Jan 08, 2013 at 05:23 PM

Hmm, I've never tried to do this before, but my thought would be to have an int, rather than a boolean. Then on button press, have a function that adds one to that int, yields for a second or two, then subtracts one. That way you can test for multiple presses of the same button, like 'up up up.'

Actually, that might not be the best way, because that won't let you order things. Maybe have an array of key presses as strings? Again you call a function, it adds the key to the end of the array, waits a set number of seconds, then removes it. You check the array on each key press, and if it matches any one of a number of preset combinations, you do your combo move.

Sounds like a fun thing to do.

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 Lboy · Jan 10, 2013 at 08:04 PM 0
Share

hmm, ok im not too familiar with Arrays and how they work so maybe i should start with something simpler i.e a script that triggers the various animations with the different key presses, then add an array as you said. thanks

avatar image
0

Answer by cgjerry87 · Apr 22, 2014 at 08:26 PM

Something that it came to me is: having an int represents each botton key. Then an int array which reads when keys are pressed and finally use cases on int combinations of the int array, to have the corresponding movement. (Also when it reads the array having a time delay between each stroke to read next or start from zero) so it doesn't reads previous keystrokes if time passed.Needs a time offset. Since u r using mechanim it reads input data of axis or any input so this is great for continues movement to blend combos

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 andyspeak · May 05, 2014 at 10:51 AM

you should look into mecanim trigger its like a bool but it auto resets when you use it so you could do on button down activate trigger and then keep taping to keep the trigger active and have the animation on a exit time so if you dont get a trigger it will go back to idle of wat u want

https://docs.unity3d.com/Documentation/ScriptReference/Animator.SetTrigger.html link to trigger doc

but my problem is timeing the animtatin for an even like i set waitForEndFrame so it has time to change the animation then yeild wait animation length or what u need the active event but timing it is hard lol i am goin to try a time.deltatime when i get home

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 andyspeak · May 05, 2014 at 10:46 AM 0
Share

u can also use the yeild return wait animeation.length /2 and add a gleam partical effect for the combo activation so u know when to tap and add bouns

and retern new 1 //is num frames 0 is 1 lol

will give the animation time to change its only like 0.04secs so u wont see it but is you call event to soon it will use the length of the animation before and the ti$$anonymous$$g will be off

p.s i use c# its alot stricter so easy to mes up but cleaner code

avatar image
0

Answer by dudedude123 · May 22, 2014 at 07:53 PM

I have it taken care of in my video

http://youtu.be/17YltNNzUok

But if you prefer button mashing

 if (Input.GetButtonUp("Punch"))
             {
                 animator.SetBool("punch", true);                
             }
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

12 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

Related Questions

How to make camera position relative to a specific target. 1 Answer

Turning to face movement direction 0 Answers

unexpected movement with mecanim 0 Answers

Multiple movement modes in mecanim 0 Answers

Basic animation key press 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