Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by asiertroiti · Mar 29, 2020 at 10:33 AM · how to

How to make a character make different hitting animations with the same button?

alt texthello, I have a question or problem, the thing is that I want to have 3 different animations of basic blows and I want each one to be done with the same button that I have assigned to it in the inputs, the thing is that when you hit the button (in this case 1) performs the animation of the first basic hit but in the animator does not perform the animation back to the static pose ... and after that they would be so that the other blows are made and that when doing the 3. it is restarted to the first one again, but I do not know how to write it in the script or if I have something to change in the animator, I would like to know how they would do it others. this is my script and as I have it in the unity the animator:

alt text

scrptpersonaje.jpg (303.2 kB)
animatorunity.jpg (426.6 kB)
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 Drislak · Apr 01, 2020 at 04:37 PM 0
Share

Hi, first of all: holy shit that is an incredible Skybox. If you have made this Skybox and / or models yourself, please add me on Discord: Drissy#2509. Or if you just want to talk too of course ;)


For the solution. What I'd do is keep a variable wherever you keep the Animator. As you want three states, you could simply do the following:

 private int _animationIndex = 0;
 
 // do other code
 
 Animator.SetInteger("index", _animationIndex++);

Afterwards, adapt your Blend Tree to include the parameter "index" (or rename it to something more specific). Then you add this check to transition to one of the three respective animations. Hope this helps.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · Mar 29, 2020 at 01:54 PM

Hello.

Never post code as a image, use the code sampler button (or Crtl+K)

And regarding your question, you just need to store each animation in a array

 Animation[] AnimationsList

Then use Random.Range to select one animation of the array.

 Animation [Random.Range(0,AnimationsList.Length)]

Bye!

Comment
Add comment · Show 2 · 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 asiertroiti · Mar 31, 2020 at 03:39 PM 0
Share

I don't know where that code sample button is ... and the CRTL + K doesn't work for me and what about the random.range where would you put it? I have been doing tests and I skipped errors no matter where I put it ...

avatar image Drislak asiertroiti · Apr 01, 2020 at 04:18 PM 0
Share

Using this solution means you'd have to adapt your animations in run-time, you shouldn't have to do that. $$anonymous$$y reply will appear in one $$anonymous$$ute.

avatar image
0

Answer by asiertroiti · Apr 01, 2020 at 02:23 PM

@tormentoarmagedoom I don't know where that code sample button is ... and the CRTL + K doesn't work for me and what about the random.range where would you put it? I have been doing tests and I skipped errors no matter where I put it ...

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

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

Where to go from here? 1 Answer

SceneManager: how can I find GameObject in another scene? 1 Answer

i want my sphere character launched to the air when he hits collider. how to do this? 1 Answer

Why unity changing my any sprite colours? 0 Answers

Photon Unity Multiplayer Teams 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